| 1 |
/* PR tree-optimization/57233 */ |
| 2 |
/* { dg-do run { target { ilp32 || lp64 } } } */ |
| 3 |
/* { dg-options "-O2" } */ |
| 4 |
/* { dg-additional-options "-fno-common" { target hppa*-*-hpux* } } */ |
| 5 |
|
| 6 |
typedef unsigned V4 __attribute__((vector_size(4 * sizeof (int)))); |
| 7 |
typedef unsigned V8 __attribute__((vector_size(8 * sizeof (int)))); |
| 8 |
typedef unsigned V16 __attribute__((vector_size(16 * sizeof (int)))); |
| 9 |
V4 a, b, g; |
| 10 |
V8 c, d, h; |
| 11 |
V16 e, f, j; |
| 12 |
|
| 13 |
__attribute__((noinline)) void |
| 14 |
f1 (void) |
| 15 |
{ |
| 16 |
a = (a << 2) | (a >> 30); |
| 17 |
} |
| 18 |
|
| 19 |
__attribute__((noinline)) void |
| 20 |
f2 (void) |
| 21 |
{ |
| 22 |
a = (a << 30) | (a >> 2); |
| 23 |
} |
| 24 |
|
| 25 |
__attribute__((noinline)) void |
| 26 |
f3 (void) |
| 27 |
{ |
| 28 |
a = (a << b) | (a >> (32 - b)); |
| 29 |
} |
| 30 |
|
| 31 |
__attribute__((noinline, noclone)) void |
| 32 |
f4 (int x) |
| 33 |
{ |
| 34 |
a = (a << x) | (a >> (32 - x)); |
| 35 |
} |
| 36 |
|
| 37 |
__attribute__((noinline)) void |
| 38 |
f5 (void) |
| 39 |
{ |
| 40 |
c = (c << 2) | (c >> 30); |
| 41 |
} |
| 42 |
|
| 43 |
__attribute__((noinline)) void |
| 44 |
f6 (void) |
| 45 |
{ |
| 46 |
c = (c << 30) | (c >> 2); |
| 47 |
} |
| 48 |
|
| 49 |
__attribute__((noinline)) void |
| 50 |
f7 (void) |
| 51 |
{ |
| 52 |
c = (c << d) | (c >> (32 - d)); |
| 53 |
} |
| 54 |
|
| 55 |
__attribute__((noinline, noclone)) void |
| 56 |
f8 (int x) |
| 57 |
{ |
| 58 |
c = (c << x) | (c >> (32 - x)); |
| 59 |
} |
| 60 |
|
| 61 |
__attribute__((noinline)) void |
| 62 |
f9 (void) |
| 63 |
{ |
| 64 |
e = (e << 2) | (e >> 30); |
| 65 |
} |
| 66 |
|
| 67 |
__attribute__((noinline)) void |
| 68 |
f10 (void) |
| 69 |
{ |
| 70 |
e = (e << 30) | (e >> 2); |
| 71 |
} |
| 72 |
|
| 73 |
__attribute__((noinline)) void |
| 74 |
f11 (void) |
| 75 |
{ |
| 76 |
e = (e << f) | (e >> (32 - f)); |
| 77 |
} |
| 78 |
|
| 79 |
__attribute__((noinline, noclone)) void |
| 80 |
f12 (int x) |
| 81 |
{ |
| 82 |
e = (e << x) | (e >> (32 - x)); |
| 83 |
} |
| 84 |
|
| 85 |
unsigned |
| 86 |
r (void) |
| 87 |
{ |
| 88 |
static unsigned x = 0xdeadbeefU; |
| 89 |
static unsigned y = 0x12347654U; |
| 90 |
static unsigned z = 0x1a2b3c4dU; |
| 91 |
static unsigned w = 0x87654321U; |
| 92 |
unsigned t = x ^ (x << 11); |
| 93 |
x = y; |
| 94 |
y = z; |
| 95 |
z = w; |
| 96 |
w = w ^ (w >> 19) ^ t ^ (t >> 8); |
| 97 |
return w; |
| 98 |
} |
| 99 |
|
| 100 |
void |
| 101 |
init (unsigned int *p, int count, int mod) |
| 102 |
{ |
| 103 |
int i; |
| 104 |
for (i = 0; i < count; i++) |
| 105 |
{ |
| 106 |
unsigned int v = r (); |
| 107 |
if (mod) |
| 108 |
v = (v % 31) + 1; |
| 109 |
p[i] = v; |
| 110 |
} |
| 111 |
} |
| 112 |
|
| 113 |
void |
| 114 |
check (unsigned int *p, unsigned int *q, int count, unsigned int *s, int ss) |
| 115 |
{ |
| 116 |
int i; |
| 117 |
for (i = 0; i < count; i++) |
| 118 |
{ |
| 119 |
if (s) |
| 120 |
ss = s[i]; |
| 121 |
if (p[i] != ((q[i] << ss) | (q[i] >> (32 - ss)))) |
| 122 |
__builtin_abort (); |
| 123 |
} |
| 124 |
} |
| 125 |
|
| 126 |
int |
| 127 |
main () |
| 128 |
{ |
| 129 |
init ((unsigned int *) &a, 4, 0); |
| 130 |
init ((unsigned int *) &b, 4, 1); |
| 131 |
init ((unsigned int *) &c, 8, 0); |
| 132 |
init ((unsigned int *) &d, 8, 1); |
| 133 |
init ((unsigned int *) &e, 16, 0); |
| 134 |
init ((unsigned int *) &f, 16, 1); |
| 135 |
g = a; |
| 136 |
h = c; |
| 137 |
j = e; |
| 138 |
f1 (); |
| 139 |
f5 (); |
| 140 |
f9 (); |
| 141 |
check ((unsigned int *) &a, (unsigned int *) &g, 4, 0, 2); |
| 142 |
check ((unsigned int *) &c, (unsigned int *) &h, 8, 0, 2); |
| 143 |
check ((unsigned int *) &e, (unsigned int *) &j, 16, 0, 2); |
| 144 |
g = a; |
| 145 |
h = c; |
| 146 |
j = e; |
| 147 |
f2 (); |
| 148 |
f6 (); |
| 149 |
f10 (); |
| 150 |
check ((unsigned int *) &a, (unsigned int *) &g, 4, 0, 30); |
| 151 |
check ((unsigned int *) &c, (unsigned int *) &h, 8, 0, 30); |
| 152 |
check ((unsigned int *) &e, (unsigned int *) &j, 16, 0, 30); |
| 153 |
g = a; |
| 154 |
h = c; |
| 155 |
j = e; |
| 156 |
f3 (); |
| 157 |
f7 (); |
| 158 |
f11 (); |
| 159 |
check ((unsigned int *) &a, (unsigned int *) &g, 4, (unsigned int *) &b, 0); |
| 160 |
check ((unsigned int *) &c, (unsigned int *) &h, 8, (unsigned int *) &d, 0); |
| 161 |
check ((unsigned int *) &e, (unsigned int *) &j, 16, (unsigned int *) &f, 0); |
| 162 |
g = a; |
| 163 |
h = c; |
| 164 |
j = e; |
| 165 |
f4 (5); |
| 166 |
f8 (5); |
| 167 |
f12 (5); |
| 168 |
check ((unsigned int *) &a, (unsigned int *) &g, 4, 0, 5); |
| 169 |
check ((unsigned int *) &c, (unsigned int *) &h, 8, 0, 5); |
| 170 |
check ((unsigned int *) &e, (unsigned int *) &j, 16, 0, 5); |
| 171 |
return 0; |
| 172 |
} |