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

Roland Scheidegger sroland at vmware.com
Fri Jul 31 17:59:57 PDT 2015


Am 01.08.2015 um 02:44 schrieb Matt Turner:
> 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.
Well, the old F_TO_I code had inline asm for both msvc and gcc using
fist. I guess though you'd actually wanted to use that only if NOT
-mfpmath=sse was specified, not sure if you could easily detect that,
otherwise use the sse variant.
In any case I'm not terribly sad to not see that code here again, it's
really the compilers job to do that with lrintf, so I'd rather see the
compilers fixed than having even more workarounds.

Roland


> 
>> (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.
> _______________________________________________
> mesa-dev mailing list
> mesa-dev at lists.freedesktop.org
> http://lists.freedesktop.org/mailman/listinfo/mesa-dev
> 



More information about the mesa-dev mailing list