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

Chris Lattner clattner at apple.com
Mon Apr 25 13:47:58 PDT 2011


On Apr 25, 2011, at 1:24 PM, Jonathan Sauer wrote:

> 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.

Patch looks great, applied in r130149, thanks!  These must be macros because __builtin_shufflevector requires that the indices be constants.

-Chris



More information about the cfe-dev mailing list