| 1 |
/* { dg-do run } */ |
| 2 |
/* { dg-options "-O2 -fipa-sra -fdump-ipa-sra" } */ |
| 3 |
|
| 4 |
/* Check of a recursive by-reference structure split. The recursive functions |
| 5 |
have to be pure right from the start, otherwise the current AA would detect |
| 6 |
possible modification of data. */ |
| 7 |
|
| 8 |
struct S |
| 9 |
{ |
| 10 |
float red; |
| 11 |
void *blue; |
| 12 |
int green; |
| 13 |
}; |
| 14 |
|
| 15 |
void __attribute__((noipa)) |
| 16 |
check (float r, int g, int g2) |
| 17 |
{ |
| 18 |
if (r < 7.39 || r > 7.41 |
| 19 |
|| g != 6 || g2 != 6) |
| 20 |
__builtin_abort (); |
| 21 |
return; |
| 22 |
} |
| 23 |
|
| 24 |
static int __attribute__((noinline, pure)) bar (struct S *s, int rec); |
| 25 |
|
| 26 |
static int |
| 27 |
__attribute__((noinline, pure)) |
| 28 |
foo (struct S *s , int rec) |
| 29 |
{ |
| 30 |
int t = 0; |
| 31 |
if (rec) |
| 32 |
t = bar (s, 0); |
| 33 |
check (s->red, s->green, s->green); |
| 34 |
return t; |
| 35 |
} |
| 36 |
|
| 37 |
static int |
| 38 |
__attribute__((noinline, pure)) |
| 39 |
bar (struct S *s, int rec) |
| 40 |
{ |
| 41 |
int t = foo (s, rec); |
| 42 |
return t + t; |
| 43 |
} |
| 44 |
|
| 45 |
volatile int g; |
| 46 |
|
| 47 |
int |
| 48 |
main (int argc, char **argv) |
| 49 |
{ |
| 50 |
struct S s; |
| 51 |
|
| 52 |
s.red = 7.4; |
| 53 |
s.green = 6; |
| 54 |
s.blue = &s; |
| 55 |
|
| 56 |
g = bar (&s, 1); |
| 57 |
return 0; |
| 58 |
} |
| 59 |
|
| 60 |
/* { dg-final { scan-ipa-dump-times "Will split parameter" 2 "sra" } } */ |
| 61 |
/* { dg-final { scan-ipa-dump-times "component at byte offset" 4 "sra" } } */ |