libcpp, c, middle-end: Optimize initializers using #embed in C
[official-gcc.git] / gcc / testsuite / gcc.dg / tree-ssa / pr91680.c
blob6d1912be005df22acbb52433fb925a49e1f9e491
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" } } */
7 __attribute__((noipa)) unsigned long long
8 foo (unsigned char x)
10 unsigned long long q = 1 << x;
11 return 256 / q;
14 __attribute__((noipa)) unsigned long long
15 bar (unsigned char x)
17 unsigned long long q = 1U << x;
18 return 256 / q;
21 __attribute__((noipa)) unsigned long long
22 baz (unsigned char x, unsigned long long y)
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;
32 __attribute__((noipa)) unsigned long long
33 qux (unsigned char x, unsigned long long y)
35 unsigned long long q = 1U << x;
36 return y / q;