PR c/64856
[official-gcc.git] / gcc / testsuite / gcc.dg / vshift-3.c
blob367e66065510f6b3b0cb30b3dd07c9ae9567cd9d
1 /* { dg-do run } */
2 /* { dg-options "-O3" } */
4 #include <stdlib.h>
6 #define N 64
8 #ifndef TYPE1
9 #define TYPE1 int
10 #define TYPE2 long long
11 #endif
13 signed TYPE1 a[N], b, g[N];
14 unsigned TYPE1 c[N], h[N];
15 signed TYPE2 d[N], e, j[N];
16 unsigned TYPE2 f[N], k[N];
18 #ifndef S
19 #define S(x) x
20 #endif
22 __attribute__((noinline)) void
23 f1 (void)
25 int i;
26 for (i = 0; i < N; i++)
27 g[i] = a[i] << S (b);
30 __attribute__((noinline)) void
31 f2 (void)
33 int i;
34 for (i = 0; i < N; i++)
35 g[i] = a[i] >> S (b);
38 __attribute__((noinline)) void
39 f3 (void)
41 int i;
42 for (i = 0; i < N; i++)
43 h[i] = c[i] >> S (b);
46 __attribute__((noinline)) void
47 f4 (void)
49 int i;
50 for (i = 0; i < N; i++)
51 j[i] = d[i] << S (e);
54 __attribute__((noinline)) void
55 f5 (void)
57 int i;
58 for (i = 0; i < N; i++)
59 j[i] = d[i] >> S (e);
62 __attribute__((noinline)) void
63 f6 (void)
65 int i;
66 for (i = 0; i < N; i++)
67 k[i] = f[i] >> S (e);
70 __attribute__((noinline)) void
71 f7 (void)
73 int i;
74 for (i = 0; i < N; i++)
75 j[i] = d[i] << S (b);
78 __attribute__((noinline)) void
79 f8 (void)
81 int i;
82 for (i = 0; i < N; i++)
83 j[i] = d[i] >> S (b);
86 __attribute__((noinline)) void
87 f9 (void)
89 int i;
90 for (i = 0; i < N; i++)
91 k[i] = f[i] >> S (b);
94 int
95 main ()
97 int i;
98 b = 7;
99 e = 12;
100 for (i = 0; i < N; i++)
102 asm ("");
103 c[i] = (rand () << 1) | (rand () & 1);
104 a[i] = c[i];
105 d[i] = (rand () << 1) | (rand () & 1);
106 d[i] |= (unsigned long long) c[i] << 32;
107 f[i] = d[i];
109 f1 ();
110 f3 ();
111 f4 ();
112 f6 ();
113 for (i = 0; i < N; i++)
114 if (g[i] != (signed TYPE1) (a[i] << S (b))
115 || h[i] != (unsigned TYPE1) (c[i] >> S (b))
116 || j[i] != (signed TYPE2) (d[i] << S (e))
117 || k[i] != (unsigned TYPE2) (f[i] >> S (e)))
118 abort ();
119 f2 ();
120 f5 ();
121 f9 ();
122 for (i = 0; i < N; i++)
123 if (g[i] != (signed TYPE1) (a[i] >> S (b))
124 || j[i] != (signed TYPE2) (d[i] >> S (e))
125 || k[i] != (unsigned TYPE2) (f[i] >> S (b)))
126 abort ();
127 f7 ();
128 for (i = 0; i < N; i++)
129 if (j[i] != (signed TYPE2) (d[i] << S (b)))
130 abort ();
131 f8 ();
132 for (i = 0; i < N; i++)
133 if (j[i] != (signed TYPE2) (d[i] >> S (b)))
134 abort ();
135 return 0;