[cfe-dev] clang, C++ and compound literals in SSE2 intrinsics

Jonathan Sauer jonathan.sauer at gmx.de
Mon Apr 25 13:24:46 PDT 2011


Hello,

> Warnings are disabled for system headers in general.  The issue here is that he warning is coming from a macro that is instantiated from a system header.  There are two more solutions:
> 
> 1a: Fix #defines to avoid compound literals.
> 
> 3. Change the compound literal warning to not fire if the expansion is from a system header.
> 
> I'd prefer 1a.

Well, I looked a bit further into the header and attempted to implement 1a. I tested _mm_shuffle_epi32 in
a simple test program, and the code generated by clang was the same before and after[*]. I have attached a
patch (diff in directory tools/clang).

As seen in the diff, I simply changed the compound literal to the appropriate _mm_set_* function. Another
possibility would be to change _mm_shuffle_* from a macro to a function, but I assume there is a reason it
is currently implemented as a macro and not, as most of the other intrinsics, a function. So I'm a bit
reluctant here.

Perhaps someone with more SSE experience than I can look into it.


Jonathan

[*] Unfortunately, I cannot test the change with the code that produced the warning in the first place, as I
replaced it just today with OpenGL-based instancing ...
-------------- next part --------------
A non-text attachment was scrubbed...
Name: emmintrin.diff
Type: application/octet-stream
Size: 1351 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-dev/attachments/20110425/8d1a1cb6/attachment.obj>
-------------- next part --------------




More information about the cfe-dev mailing list