OSDN Git Service

Backported from mainline
[pf3gnuchains/gcc-fork.git] / gcc / testsuite / gcc.c-torture / execute / 20050316-1.c
1 /* PR rtl-optimization/16104 */
2
3 extern void abort (void);
4
5 typedef int V2SI __attribute__ ((vector_size (8)));
6 typedef unsigned int V2USI __attribute__ ((vector_size (8)));
7 typedef short V2HI __attribute__ ((vector_size (4)));
8 typedef unsigned int V2UHI __attribute__ ((vector_size (4)));
9
10 int
11 test1 (void)
12 {
13   return (long long) (V2SI) 0LL;
14 }
15
16 int
17 test2 (V2SI x)
18 {
19   return (long long) x;
20 }
21
22 V2SI
23 test3 (void)
24 {
25   return (V2SI) (long long) (int) (V2HI) 0;
26 }
27
28 V2SI
29 test4 (V2HI x)
30 {
31   return (V2SI) (long long) (int) x;
32 }
33
34 V2SI
35 test5 (V2USI x)
36 {
37   return (V2SI) x;
38 }
39
40 int
41 main (void)
42 {
43   if (sizeof (short) != 2 || sizeof (int) != 4 || sizeof (long long) != 8)
44     return 0;
45
46   if (test1 () != 0)
47     abort ();
48
49   V2SI x = { 2, 2 };
50   if (test2 (x) != 2)
51     abort ();
52
53   union { V2SI x; int y[2]; V2USI z; long long l; } u;
54   u.x = test3 ();
55   if (u.y[0] != 0 || u.y[1] != 0)
56     abort ();
57
58   V2HI y = { 4, 4 };
59   union { V2SI x; long long y; } v;
60   v.x = test4 (y);
61   if (v.y != 0x40004)
62     abort ();
63
64   V2USI z = { 6, 6 };
65   u.x = test5 (z);
66   if (u.y[0] != 6 || u.y[1] != 6)
67     abort ();
68   return 0;
69 }