[C++] Fix __builtin_shuffle
Marc Glisse
marc.glisse@inria.fr
Fri Jun 28 08:48:00 GMT 2013
On Fri, 28 Jun 2013, Jakub Jelinek wrote:
> Hi!
>
> On Thu, Jun 27, 2013 at 01:59:37PM +0200, Marc Glisse wrote:
>> --- testsuite/g++.dg/ext/pr57509.C (revision 0)
>> +++ testsuite/g++.dg/ext/pr57509.C (revision 0)
>> @@ -0,0 +1,16 @@
>> +/* { dg-do compile } */
>> +/* { dg-options "-std=c++11" } */
>> +
>> +template <bool> struct enable_if {};
>> +template <> struct enable_if<true> {typedef void type;};
>> +template <class T> void f (T& v) { v = __builtin_shuffle (v, v); }
>> +template <class T> void g (T) {}
>> +template <class T> auto g (T x) -> typename enable_if<sizeof(__builtin_shuffle(x,x))!=2>::type {}
>> +typedef int v4i __attribute__((vector_size(4*sizeof(int))));
>> +typedef float v4f __attribute__((vector_size(4*sizeof(float))));
>> +int main(){
>> + v4i a = {1,2,3,0};
>> + f(a);
>> + v4f b = {1,2,3,0};
>> + g(b);
>> +}
>
> Note this testcase fails on i686-linux:
> /usr/src/gcc/gcc/testsuite/g++.dg/ext/pr57509.C: In function 'int main()':
> /usr/src/gcc/gcc/testsuite/g++.dg/ext/pr57509.C:15:7: warning: SSE vector argument without SSE enabled changes the ABI [enabled by default]
> /usr/src/gcc/gcc/testsuite/g++.dg/ext/pr57509.C:15:7: warning: SSE vector argument without SSE enabled changes the ABI [enabled by default]
> /usr/src/gcc/gcc/testsuite/g++.dg/ext/pr57509.C:15:7: note: The ABI for passing parameters with 16-byte alignment has changed in GCC 4.6
Gah, I know about this warning (that's why I pass vectors by pointer in
most testcases) but somehow keep forgetting it :-(
> The note is actually pruned, but the warnings aren't. -Wno-abi -Wno-psabi
> doesn't help,
I think it is a bug that the warning doesn't have an associated -Wxxx.
Should it use -Wabi, -Wpsabi, or some new flag like -Wunsupported-vector?
> but -w does, so I'd suggest just to add -w to dg-options.
It seems better to do the following, so we still test for extra warnings:
-template <class T> void g (T) {}
-template <class T> auto g (T x) -> typename enable_if<sizeof(__builtin_shuffle(x,x))!=2>::type {}
+template <class T> void g (T const&) {}
+template <class T> auto g (T const& x) -> typename enable_if<sizeof(__builtin_shuffle(x,x))!=2>::type {}
Ok?
--
Marc Glisse
More information about the Gcc-patches
mailing list