[Mesa-dev] [PATCH 5/7] util: Use SSE intrinsics in _mesa_lroundeven{f, }.

Matt Turner mattst88 at gmail.com
Fri Jul 31 17:44:52 PDT 2015


On Fri, Jul 31, 2015 at 4:41 PM, Ilia Mirkin <imirkin at alum.mit.edu> wrote:
> On Fri, Jul 31, 2015 at 7:26 PM, Matt Turner <mattst88 at gmail.com> wrote:
>> gcc actually generates this for us now that we use -fno-math-errno
>> (which is weird, since lrintf()/lrint() don't set errno) but clang still
>> does not. Presumably helps MSVC as well.
>>
>> Reduced .text size by 8.5k with gcc before -fno-math-errno.
>>
>>    text     data      bss      dec      hex  filename
>> 4935850   195136    26192  5157178   4eb13a  i965_dri.so before
>> 4927225   195128    26192  5148545   4e8f81  i965_dri.so after
>> ---
>>  src/util/rounding.h | 13 +++++++++++++
>>  1 file changed, 13 insertions(+)
>>
>> diff --git a/src/util/rounding.h b/src/util/rounding.h
>> index 2d00760..e546c9f 100644
>> --- a/src/util/rounding.h
>> +++ b/src/util/rounding.h
>> @@ -26,6 +26,11 @@
>>
>>  #include <math.h>
>>
>> +#ifdef __x86_64__
>> +#include <xmmintrin.h>
>> +#include <emmintrin.h>
>> +#endif
>> +
>>  #ifdef __SSE4_1__
>>  #include <smmintrin.h>
>>  #endif
>
> Not that I object to any of this, but
>
> (a) this stuff is presumably also available on 32-bit, so should
> probably be based on __SSE2__.

That's true, but unless you're compiling with -mfpmath=sse then you're
using the FPU, so using SSE intrinsics involves some copies to and
from memory.

> (b) you can just include <immintrin.h> which is safe to include on
> x86(_64) and then you get all the functions you're supposed to.

Looking in gcc's SVN, immintrin.h seems to have been added Nov 21 2008
which is after the 4.2 and 4.3 releases which we still support.

In general I'm kind of wary of using immintrin.h since you don't
actually know what you get from it.


More information about the mesa-dev mailing list