| 1 |
/* { dg-do compile } */ |
| 2 |
/* { dg-options "-O2 -fdump-ipa-sra -fdump-tree-optimized" } */ |
| 3 |
|
| 4 |
#define DOIT |
| 5 |
#define DONT |
| 6 |
|
| 7 |
|
| 8 |
extern int extern_leaf (int); |
| 9 |
|
| 10 |
/* ----- 1 ----- */ |
| 11 |
#ifdef DOIT |
| 12 |
static int __attribute__((noinline)) |
| 13 |
whee_1 (int i, int j) |
| 14 |
{ |
| 15 |
return extern_leaf (i * j) + 1; |
| 16 |
} |
| 17 |
|
| 18 |
static int foo_1 (int i, int j); |
| 19 |
|
| 20 |
static int __attribute__((noinline)) |
| 21 |
baz_1 (int i, int j) |
| 22 |
{ |
| 23 |
int a = 5; |
| 24 |
if (j) |
| 25 |
a = foo_1 (i, j - 1); |
| 26 |
return whee_1 (i, j) + a + 1; |
| 27 |
} |
| 28 |
|
| 29 |
static int __attribute__((noinline)) |
| 30 |
bar_1 (int i, int j) |
| 31 |
{ |
| 32 |
return baz_1 (i, j) + 1; |
| 33 |
} |
| 34 |
|
| 35 |
static int __attribute__((noinline)) |
| 36 |
foo_1 (int i, int j) |
| 37 |
{ |
| 38 |
return bar_1 (i, j) + 1; |
| 39 |
} |
| 40 |
|
| 41 |
static int __attribute__((noinline)) |
| 42 |
inter_1 (int i, int j) |
| 43 |
{ |
| 44 |
return foo_1 (i, j) + 1; |
| 45 |
} |
| 46 |
#endif |
| 47 |
|
| 48 |
/* ----- 2 ----- */ |
| 49 |
#ifdef DONT |
| 50 |
static int __attribute__((noinline)) |
| 51 |
whee_2 (int i, int j) |
| 52 |
{ |
| 53 |
return extern_leaf (i * j) + 2; |
| 54 |
} |
| 55 |
|
| 56 |
static int foo_2 (int i, int j); |
| 57 |
|
| 58 |
static int __attribute__((noinline)) |
| 59 |
baz_2 (int i, int j) |
| 60 |
{ |
| 61 |
int a = 6; |
| 62 |
if (j) |
| 63 |
a = foo_2 (i, j - 1); |
| 64 |
return whee_2 (i, j) + a + 2; |
| 65 |
} |
| 66 |
|
| 67 |
static int __attribute__((noinline)) |
| 68 |
bar_2 (int i, int j) |
| 69 |
{ |
| 70 |
return baz_2 (i, j) + 2; |
| 71 |
} |
| 72 |
|
| 73 |
static int __attribute__((noinline)) |
| 74 |
foo_2 (int i, int j) |
| 75 |
{ |
| 76 |
return bar_2 (i, j) + 2; |
| 77 |
} |
| 78 |
#endif |
| 79 |
|
| 80 |
/* ----- entries ----- */ |
| 81 |
#ifdef DOIT |
| 82 |
int |
| 83 |
entry_1 (int i, int j) |
| 84 |
{ |
| 85 |
inter_1 (i, j); |
| 86 |
return i + j + 1; |
| 87 |
} |
| 88 |
#endif |
| 89 |
|
| 90 |
#ifdef DONT |
| 91 |
int |
| 92 |
entry_2 (int i, int j) |
| 93 |
{ |
| 94 |
#ifdef DOIT |
| 95 |
inter_1 (i, j); |
| 96 |
#endif |
| 97 |
return i + j + bar_2 (i, j); |
| 98 |
} |
| 99 |
#endif |
| 100 |
|
| 101 |
/* { dg-final { scan-ipa-dump-times "Will remove return value" 5 "sra" } } */ |
| 102 |
/* { dg-final { scan-tree-dump-times "return;" 5 "optimized"} } */ |