OSDN Git Service

* gcc.dg/torture/builtin-modf-1.c: Remove -funsafe-math-optimizations.
[pf3gnuchains/gcc-fork.git] / gcc / testsuite / gcc.dg / torture / pr16104-1.c
1 /* PR rtl-optimization/16104 */
2 /* { dg-do run { target i?86-*-* x86_64-*-* } } */
3 /* { dg-options "-msse2" } */
4
5 #include "cpuid.h"
6
7 extern void abort (void);
8
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)));
13
14 int
15 test1 (void)
16 {
17   return (long long) (V2SI) 0LL;
18 }
19
20 int
21 test2 (V2SI x)
22 {
23   return (long long) x;
24 }
25
26 V2SI
27 test3 (void)
28 {
29   return (V2SI) (long long) (int) (V2HI) 0;
30 }
31
32 V2SI
33 test4 (V2HI x)
34 {
35   return (V2SI) (long long) (int) x;
36 }
37
38 V2SI
39 test5 (V2USI x)
40 {
41   return (V2SI) x;
42 }
43
44 void
45 __attribute__ ((noinline))
46 do_test (void)
47 {
48   if (sizeof (short) != 2 || sizeof (int) != 4 || sizeof (long long) != 8)
49     return;
50
51   if (test1 () != 0)
52     abort ();
53
54   V2SI x = { 2, 2 };
55   if (test2 (x) != 2)
56     abort ();
57
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 ();
62
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 ();
68
69   V2USI z = { 6, 6 };
70   u.x = test5 (z);
71   if (u.y[0] != 6 || u.y[1] != 6)
72     abort ();
73 }
74
75 int
76 main (void)
77 {
78   unsigned int eax, ebx, ecx, edx;
79  
80   if (!__get_cpuid (1, &eax, &ebx, &ecx, &edx))
81     return 0;
82
83   /* Run SSE2 test only if host has SSE2 support.  */
84   if (edx & bit_SSE2)
85     do_test ();
86
87   return 0;
88 }