[Mesa-dev] [PATCH 3/3] util: Use SSE rounding on all platforms that support it.

Jose Fonseca jfonseca at vmware.com
Sun Aug 9 11:16:48 PDT 2015


On 09/08/15 17:47, Matt Turner wrote:
> On Sun, Aug 9, 2015 at 3:57 AM, Jose Fonseca <jfonseca at vmware.com> wrote:
>> As currently only GCC x86_64 builds where using it.
>> ---
>>   src/util/rounding.h | 16 +++++++++++++---
>>   1 file changed, 13 insertions(+), 3 deletions(-)
>>
>> diff --git a/src/util/rounding.h b/src/util/rounding.h
>> index ec31b47..38c1c2f 100644
>> --- a/src/util/rounding.h
>> +++ b/src/util/rounding.h
>> @@ -27,7 +27,17 @@
>>   #include <math.h>
>>   #include <limits.h>
>>
>> -#ifdef __x86_64__
>> +/* SSE2 is supported on: all x86_64 targets, on x86 targets when -msse2 is
>> + * passed to GCC, and should also be enabled on all Windows builds. */
>> +#if defined(__x86_64__) /* gcc */ || \
>> +    defined(_M_X64) /* msvc */ || \
>> +    defined(_M_AMD64) /* msvc */ || \
>> +    defined(__SSE2__) /* gcc -msse2 */ || \
>
> I don't think we should include __SSE2__ in this. On x86-32,
> floating-point operations will be using the x87 FPU, so using SSE
> intrinsics will force some transfers to and from memory.

I don't see why not.  It would be just missing out good opportunities to 
use this.

__SSE2__ is defined is -msse2 option is set.  And it makes no sense to 
set -msse2 without -fpmath=sse, as it would be inefficient.

In fact, I think I read that with GCC 5 -msse implies -mfpmath=sse.

>
>> +    defined(_WIN32)
>> +#define HAVE_SSE2 1
>
> Does MSVC define __amd64, __amd64__, or __x86_64? The AMD64 ABI
> document says these, and __x86_64__ should be defined if compiling on
> x86-64.

I'm afraid MSVC doesn't.  See 
https://msdn.microsoft.com/en-us/library/b0084kay.aspx

This logic was taken from p_config.h.

I believe that the Windows amd64 abi is not 100% identical to the linux ABI.


Jose


More information about the mesa-dev mailing list