| 1 |
/* { dg-do run { target aarch64*-*-* } } */ |
| 2 |
/* { dg-options "-O" } */ |
| 3 |
|
| 4 |
typedef signed long long int S; |
| 5 |
typedef unsigned long long int U; |
| 6 |
typedef __int128 W; |
| 7 |
__attribute__ ((noinline, noclone)) |
| 8 |
U upseu (U x, S y, int *ovf) |
| 9 |
{ |
| 10 |
U res; |
| 11 |
*ovf = __builtin_add_overflow (x, y, &res); |
| 12 |
return res; |
| 13 |
} |
| 14 |
U |
| 15 |
usueu (U x, U y, int *ovf) |
| 16 |
{ |
| 17 |
U res; |
| 18 |
*ovf = __builtin_sub_overflow (x, y, &res); |
| 19 |
return res; |
| 20 |
} |
| 21 |
U |
| 22 |
usseu (U x, S y, int *ovf) |
| 23 |
{ |
| 24 |
U res; |
| 25 |
*ovf = __builtin_sub_overflow (x, y, &res); |
| 26 |
return res; |
| 27 |
} |
| 28 |
int |
| 29 |
main () |
| 30 |
{ |
| 31 |
int i, j; |
| 32 |
for (i = 0; i < ((unsigned char) ~0); i++) |
| 33 |
for (j = 0; j < ((unsigned char) ~0); j++) |
| 34 |
{ |
| 35 |
U u1 = ((W) i << ((8 - 1) * 8)); |
| 36 |
S s2 = ((W) j << ((8 - 1) * 8)) + (-0x7fffffffffffffffLL - 1); |
| 37 |
U u2 = ((W) j << ((8 - 1) * 8)); |
| 38 |
W w; |
| 39 |
int ovf; |
| 40 |
w = ((W) u1) + ((W) s2); |
| 41 |
if (upseu (u1, s2, &ovf) != (U) w || ovf != (w != (U) w)) |
| 42 |
__builtin_abort (); |
| 43 |
w = ((W) u1) - ((W) u2); |
| 44 |
if (usueu (u1, u2, &ovf) != (U) w || ovf != (w != (U) w)) |
| 45 |
__builtin_abort (); |
| 46 |
w = ((W) u1) - ((W) s2); |
| 47 |
if (usseu (u1, s2, &ovf) != (U) w || ovf != (w != (U) w)) |
| 48 |
__builtin_abort (); |
| 49 |
} |
| 50 |
} |