Debian Codegraph @

gcc/testsuite/gcc.dg/field-merge-24.c

raw
1 /* { dg-do run } */
2 /* { dg-options "-O2" } */
3
4 /* PR tree-optimization/118572 */
5 /* Check that signed compares with constants that seem signed in the other
6 compare operand's width get treated as unsigned if its upper bits are masked
7 out. */
8
9 __attribute__((noipa))
10 int test(signed char c)
11 {
12 return (((0x80 & (c&0xff)) != 0) && ((0xc0 & (c&0xff)) == 0x80));
13 }
14
15 __attribute__((noipa))
16 int test2(signed char c)
17 {
18 return (((-128 & (c&-1)) != 0) && ((-64 & (c&-1)) == -128));
19 }
20
21 __attribute__((noipa))
22 int test3(signed char c)
23 {
24 return (((0x80 & (c&-1)) != 0) && ((0x1248c0 & (c&-1)) == 0x124880));
25 }
26
27 __attribute__((noipa))
28 int test4(signed char c)
29 {
30 return (((0x400 & (c&-1)) == 0) && ((0x40 & (c&-1)) == 0x40));
31 }
32
33 int main() {
34 if (test(0x80) == 0 || test2(-128) == 0 || test3(-128) == 0 || test4(64) == 0)
35 __builtin_abort();
36 }