| 1 |
/* { dg-do compile } */ |
| 2 |
/* { dg-options "-O2 -fdump-tree-optimized-slim" } */ |
| 3 |
|
| 4 |
struct S |
| 5 |
{ |
| 6 |
int a, b, c; |
| 7 |
}; |
| 8 |
|
| 9 |
int ellide (int c); |
| 10 |
volatile short gi; |
| 11 |
|
| 12 |
void __attribute__((noipa)) |
| 13 |
consume_s (struct S *p) |
| 14 |
{ |
| 15 |
gi = p->a; |
| 16 |
} |
| 17 |
|
| 18 |
static void __attribute__((noinline)) |
| 19 |
foo (struct S *p, short *r) |
| 20 |
{ |
| 21 |
gi = *r; |
| 22 |
if (!__builtin_constant_p (p->b)) |
| 23 |
ellide (1); |
| 24 |
consume_s (p); |
| 25 |
} |
| 26 |
|
| 27 |
static void __attribute__((noinline)) |
| 28 |
bar (short *r, struct S *p) |
| 29 |
{ |
| 30 |
gi = *r; |
| 31 |
if (!__builtin_constant_p (p->c)) |
| 32 |
ellide (2); |
| 33 |
consume_s (p); |
| 34 |
} |
| 35 |
|
| 36 |
struct S gs; |
| 37 |
|
| 38 |
int main (int argc, char *argv[]) |
| 39 |
{ |
| 40 |
short i = 42; |
| 41 |
gs.a = 10; |
| 42 |
gs.b = 20; |
| 43 |
foo (&gs, &i); |
| 44 |
gs.b = 30; |
| 45 |
gs.c = 40; |
| 46 |
bar (&i, &gs); |
| 47 |
return 0; |
| 48 |
} |
| 49 |
|
| 50 |
/* { dg-final { scan-tree-dump-not "ellide" "optimized" { xfail *-*-* } } } */ |