Merge -r 127928:132243 from trunk
[official-gcc.git] / gcc / testsuite / gcc.dg / torture / pr16104-1.c
blob018a1bac7601e298965b5182421bc3cd6ebc871c
1 /* PR rtl-optimization/16104 */
2 /* { dg-do run { target i?86-*-* x86_64-*-* } } */
3 /* { dg-options "-msse2" } */
5 #include "cpuid.h"
7 extern void abort (void);
9 typedef int V2SI __attribute__ ((vector_size (8)));
10 typedef unsigned int V2USI __attribute__ ((vector_size (8)));
11 typedef short V2HI __attribute__ ((vector_size (4)));
12 typedef unsigned int V2UHI __attribute__ ((vector_size (4)));
14 int
15 test1 (void)
17 return (long long) (V2SI) 0LL;
20 int
21 test2 (V2SI x)
23 return (long long) x;
26 V2SI
27 test3 (void)
29 return (V2SI) (long long) (int) (V2HI) 0;
32 V2SI
33 test4 (V2HI x)
35 return (V2SI) (long long) (int) x;
38 V2SI
39 test5 (V2USI x)
41 return (V2SI) x;
44 void
45 __attribute__ ((noinline))
46 do_test (void)
48 if (sizeof (short) != 2 || sizeof (int) != 4 || sizeof (long long) != 8)
49 return;
51 if (test1 () != 0)
52 abort ();
54 V2SI x = { 2, 2 };
55 if (test2 (x) != 2)
56 abort ();
58 union { V2SI x; int y[2]; V2USI z; long long l; } u;
59 u.x = test3 ();
60 if (u.y[0] != 0 || u.y[1] != 0)
61 abort ();
63 V2HI y = { 4, 4 };
64 union { V2SI x; long long y; } v;
65 v.x = test4 (y);
66 if (v.y != 0x40004)
67 abort ();
69 V2USI z = { 6, 6 };
70 u.x = test5 (z);
71 if (u.y[0] != 6 || u.y[1] != 6)
72 abort ();
75 int
76 main (void)
78 unsigned int eax, ebx, ecx, edx;
80 if (!__get_cpuid (1, &eax, &ebx, &ecx, &edx))
81 return 0;
83 /* Run SSE2 test only if host has SSE2 support. */
84 if (edx & bit_SSE2)
85 do_test ();
87 return 0;