qemu-devel
[Top][All Lists]
Advanced

[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: Stefan Brankovic
Subject: Re: [Qemu-devel] [PATCH 7/8] target/ppc: Optimize emulation of vclzh and vclzb instructions
Date: Mon, 17 Jun 2019 13:42:28 +0200
User-agent: Mozilla/5.0 (X11; Linux x86_64; rv:60.0) Gecko/20100101 Thunderbird/60.7.0


On 6.6.19. 22:38, Richard Henderson wrote:
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 based this patch on performance results and my measurements say that tcg implementation is still significantly superior to helper implementation, regardless of somewhat large number of instructions.

I can attach both performance measurements results and disassembly of both helper and tcg implementations, if you want me to do this.


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.

I agree with this, but currently we don't have this implemented in tcg, so I worked with what I have.

Kind Regards,

Stefan

r~



reply via email to

[Prev in Thread] Current Thread [Next in Thread]