| 1 |
/* { dg-do run } */ |
| 2 |
/* { dg-require-effective-target p8vector_hw } */ |
| 3 |
/* { dg-require-effective-target int128 } */ |
| 4 |
/* { dg-options "-O2 -mdejagnu-cpu=power8" } */ |
| 5 |
|
| 6 |
/* PR 116415: Verify our Power8 swap optimization pass doesn't incorrectly swap |
| 7 |
PTImode values. They should be handled identically to TImode values. */ |
| 8 |
|
| 9 |
#include <stdio.h> |
| 10 |
#include <stdint.h> |
| 11 |
#include <stdlib.h> |
| 12 |
|
| 13 |
typedef union { |
| 14 |
struct { |
| 15 |
uint64_t a; |
| 16 |
uint64_t b; |
| 17 |
} t; |
| 18 |
__uint128_t data; |
| 19 |
} Value; |
| 20 |
Value value, next; |
| 21 |
|
| 22 |
void |
| 23 |
bug (Value *val, Value *nxt) |
| 24 |
{ |
| 25 |
for (;;) { |
| 26 |
nxt->t.a = val->t.a + 1; |
| 27 |
nxt->t.b = val->t.b + 2; |
| 28 |
if (__atomic_compare_exchange (&val->data, &val->data, &nxt->data, |
| 29 |
0, __ATOMIC_SEQ_CST, __ATOMIC_ACQUIRE)) |
| 30 |
break; |
| 31 |
} |
| 32 |
} |
| 33 |
|
| 34 |
int |
| 35 |
main (void) |
| 36 |
{ |
| 37 |
bug (&value, &next); |
| 38 |
printf ("%lu %lu\n", value.t.a, value.t.b); |
| 39 |
if (value.t.a != 1 || value.t.b != 2) |
| 40 |
abort (); |
| 41 |
return 0; |
| 42 |
} |