[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [Qemu-devel] [PATCH 7/8] target/ppc: Optimize emulation of vclzh and
From: |
Richard Henderson |
Subject: |
Re: [Qemu-devel] [PATCH 7/8] target/ppc: Optimize emulation of vclzh and vclzb instructions |
Date: |
Thu, 6 Jun 2019 15:38:12 -0500 |
User-agent: |
Mozilla/5.0 (X11; Linux x86_64; rv:60.0) Gecko/20100101 Thunderbird/60.7.0 |
On 6/6/19 5:15 AM, Stefan Brankovic wrote:
> Optimize Altivec instruction vclzh (Vector Count Leading Zeros Halfword).
> This instruction counts the number of leading zeros of each halfword element
> in source register and places result in the appropriate halfword element of
> destination register.
For halfword, you're generating 32 operations. A loop over the halfwords,
similar to the word loop I suggested for the last patch, does not reduce this
total, since one has to adjust the clz32 result.
For byte, you're generating 64 operations.
These expansions are so big that without host vector support it's probably best
to leave them out-of-line.
I can imagine a byte clz expansion like
t0 = input >> 4;
t1 = input << 4;
cmp = input == 0 ? -1 : 0;
input = cmp ? t1 : input;
output = cmp & 4;
t0 = input >> 6;
t1 = input << 2;
cmp = input == 0 ? -1 : 0;
input = cmp ? t1 : input;
t0 = cmp & 2;
output += t0;
t1 = input << 1;
cmp = input >= 0 ? -1 : 0;
output -= cmp;
cmp = input == 0 ? -1 : 0;
output -= cmp;
which would expand to 20 x86_64 vector instructions. A halfword expansion
would require one more round and thus 25 instructions.
I'll also note that ARM, Power8, and S390 all support this as a native vector
operation; only x86_64 would require the above expansion. It probably makes
sense to add this operation to tcg.
r~
- [Qemu-devel] [PATCH 1/8] target/ppc: Optimize emulation of lvsl and lvsr instructions, (continued)
- [Qemu-devel] [PATCH 1/8] target/ppc: Optimize emulation of lvsl and lvsr instructions, Stefan Brankovic, 2019/06/06
- [Qemu-devel] [PATCH 2/8] target/ppc: Optimize emulation of vsl and vsr instructions, Stefan Brankovic, 2019/06/06
- [Qemu-devel] [PATCH 4/8] target/ppc: Optimize emulation of vgbbd instruction, Stefan Brankovic, 2019/06/06
- [Qemu-devel] [PATCH 7/8] target/ppc: Optimize emulation of vclzh and vclzb instructions, Stefan Brankovic, 2019/06/06
- Re: [Qemu-devel] [PATCH 7/8] target/ppc: Optimize emulation of vclzh and vclzb instructions,
Richard Henderson <=
- [Qemu-devel] [PATCH 3/8] target/ppc: Optimize emulation of vpkpx instruction, Stefan Brankovic, 2019/06/06
- [Qemu-devel] [PATCH 5/8] target/ppc: Optimize emulation of vclzd instruction, Stefan Brankovic, 2019/06/06
- [Qemu-devel] [PATCH 8/8] target/ppc: Refactor emulation of vmrgew and vmrgow instructions, Stefan Brankovic, 2019/06/06
- [Qemu-devel] [PATCH 6/8] target/ppc: Optimize emulation of vclzw instruction, Stefan Brankovic, 2019/06/06