[Mesa-dev] [PATCH] Use signbit() in IS_NEGATIVE and DIFFERENT_SIGNS

Matt Turner mattst88 at gmail.com
Tue Sep 18 10:31:31 PDT 2012


On Mon, Sep 17, 2012 at 7:15 PM, Roland Scheidegger <sroland at vmware.com> wrote:
> Am 18.09.2012 01:34, schrieb Matt Turner:
>> Here is the assembly output of the other two (IEEE being the fi_type
>> union hack, and SIGNBIT using signbit().
>>
>> <IS_NEGATIVE_IEEE>:
>>     movd   %xmm0,%eax
>>     shr    $0x1f,%eax
>>
>> <IS_NEGATIVE_SIGNBIT>:
>>     pmovmskb %xmm0,%eax
>>     shr    $0x3,%eax
>>     and    $0x1,%eax
> What optimization level was that?

-O2 -march=native (sandybridge) -mno-avx.

> I find it interesting that it used pmovmskb/shr/and. Would be much more
> natural imho (and better) to juse use movmskps/and if it wants to
> extract the sign bit "directly" (which would probably be roughly as good
> as the union hack well there might always be some odd cpus out there
> which don't have the same performance for pmovmskb and movmskps but
> generally it should be the same).

Yeah, it seems like movmskps/and would be better. I'll poke around gcc
and file a bug.

> The result might look less pretty though when compiling on plain 32-bit
> x86 (that is, using fp stack) in any case.
> Is there actually a platform where we wouldn't have USE_IEEE?

OpenVMS. :)


More information about the mesa-dev mailing list