Debian Codegraph @

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

raw
1 /* { dg-do run } */
2 /* { dg-options "-O -fdump-tree-ifcombine-details" } */
3
4 /* Check that conversions and selections of similar bit ranges across different
5 types don't prevent combination. */
6
7 struct s1 {
8 unsigned char b[2];
9 unsigned char a;
10 } __attribute__ ((aligned (4)));
11
12 struct s2 {
13 unsigned short b;
14 unsigned char a;
15 } __attribute__ ((aligned (4)));
16
17 static const char le = __BYTE_ORDER__ == __ORDER_LITTLE_ENDIAN__ ? 1 : 0;
18
19 struct s1 p = { { -!le , -le }, 42 };
20 struct s2 q = { -2 << (__CHAR_BIT__ - 1), 42 };
21
22 void f (void) {
23 if (0
24 || p.a != q.a
25 || p.b[!le] != (unsigned char)q.b
26 || p.b[le] != (unsigned char)((q.b >> (__CHAR_BIT__ - 1)) >> 1)
27 )
28 __builtin_abort ();
29 }
30
31 int main () {
32 if (sizeof (short) != 2)
33 return 0;
34 f ();
35 return 0;
36 }
37
38 /* { dg-final { scan-tree-dump-times "optimizing two comparisons" 2 "ifcombine" { target { ! { avr-*-* pru-*-* } } } } } */