| 1 |
/* PR target/125795 */ |
| 2 |
/* { dg-do run } */ |
| 3 |
/* { dg-options "-O2 -funroll-loops" } */ |
| 4 |
|
| 5 |
/* This loop is vectorized with LD2 (deinterleave) and TBL (lane reversal), |
| 6 |
then unrolled. The unrolled body builds a full-width (32 FPR) early-ra |
| 7 |
color group, which used to trigger a "1U << 32" undefined shift in |
| 8 |
early_ra::allocate_colors. As a result the long-lived TBL permute index |
| 9 |
was wrongly allocated to the same FPR as an LD2 tuple destination and got |
| 10 |
clobbered, so the result was miscomputed. */ |
| 11 |
|
| 12 |
extern void abort (void); |
| 13 |
|
| 14 |
#define N 256 |
| 15 |
|
| 16 |
static int __attribute__ ((noipa)) |
| 17 |
foo (void) |
| 18 |
{ |
| 19 |
int k[N]; |
| 20 |
int k2[N]; |
| 21 |
int i; |
| 22 |
|
| 23 |
for (i = 0; i < N; i++) |
| 24 |
k2[i] = i; |
| 25 |
|
| 26 |
for (i = 0; i < 64; i++) |
| 27 |
{ |
| 28 |
k[i] = k2[2 * i + 0]; |
| 29 |
k[255 - i] = k2[2 * i + 1]; |
| 30 |
k[64 + i] = k2[2 * i + 128]; |
| 31 |
k[191 - i] = k2[2 * i + 129]; |
| 32 |
} |
| 33 |
|
| 34 |
for (i = 0; i < N; i++) |
| 35 |
if (k[i] != ((i < 128) ? (2 * i) : (511 - 2 * i))) |
| 36 |
return 1; |
| 37 |
|
| 38 |
return 0; |
| 39 |
} |
| 40 |
|
| 41 |
int |
| 42 |
main (void) |
| 43 |
{ |
| 44 |
if (foo ()) |
| 45 |
abort (); |
| 46 |
return 0; |
| 47 |
} |