| 1 |
/* PR middle-end/91680 */ |
| 2 |
/* { dg-do compile { target { ilp32 || lp64 } } } */ |
| 3 |
/* { dg-options "-O2 -fdump-tree-forwprop1" } */ |
| 4 |
/* { dg-final { scan-tree-dump-times " / " 1 "forwprop1" } } */ |
| 5 |
/* { dg-final { scan-tree-dump-times " >> " 3 "forwprop1" } } */ |
| 6 |
|
| 7 |
__attribute__((noipa)) unsigned long long |
| 8 |
foo (unsigned char x) |
| 9 |
{ |
| 10 |
unsigned long long q = 1 << x; |
| 11 |
return 256 / q; |
| 12 |
} |
| 13 |
|
| 14 |
__attribute__((noipa)) unsigned long long |
| 15 |
bar (unsigned char x) |
| 16 |
{ |
| 17 |
unsigned long long q = 1U << x; |
| 18 |
return 256 / q; |
| 19 |
} |
| 20 |
|
| 21 |
__attribute__((noipa)) unsigned long long |
| 22 |
baz (unsigned char x, unsigned long long y) |
| 23 |
{ |
| 24 |
/* This can't be optimized, at least not in C++ and maybe not |
| 25 |
in C89, because for x 31 q is -2147483648ULL, not |
| 26 |
2147483648ULL, and e.g. 2147483648ULL >> 31 is 1, while |
| 27 |
2147483648ULL / -2147483648ULL is 0. */ |
| 28 |
unsigned long long q = 1 << x; |
| 29 |
return y / q; |
| 30 |
} |
| 31 |
|
| 32 |
__attribute__((noipa)) unsigned long long |
| 33 |
qux (unsigned char x, unsigned long long y) |
| 34 |
{ |
| 35 |
unsigned long long q = 1U << x; |
| 36 |
return y / q; |
| 37 |
} |