| 1 |
/* { dg-do compile } */ |
| 2 |
/* { dg-options "-O2 -fipa-sra -fdump-ipa-sra -fdump-tree-optimized" } */ |
| 3 |
|
| 4 |
/* Testing removal of unused parameters in recursive calls. */ |
| 5 |
|
| 6 |
extern int work_1 (int); |
| 7 |
extern int work_2 (int); |
| 8 |
|
| 9 |
static int __attribute__((noinline)) |
| 10 |
foo (int l, int w1, int w2, int useless, int useless2); |
| 11 |
|
| 12 |
|
| 13 |
static int __attribute__((noinline)) |
| 14 |
bar_1 (int l, int w1, int w2, int useless, int useless2) |
| 15 |
{ |
| 16 |
return work_1 (w1) + foo (l, w1, w2, useless2, useless); |
| 17 |
} |
| 18 |
|
| 19 |
static int __attribute__((noinline)) |
| 20 |
baz_1 (int useless, int useless2, int l, int w1, int w2) |
| 21 |
{ |
| 22 |
return bar_1 (l, w1, w2, useless, useless2); |
| 23 |
} |
| 24 |
|
| 25 |
static int __attribute__((noinline)) |
| 26 |
bax_1 (int l, int w1, int w2, int useless, int useless2) |
| 27 |
{ |
| 28 |
return baz_1 (useless, useless2, l, w1, w2); |
| 29 |
} |
| 30 |
|
| 31 |
|
| 32 |
|
| 33 |
static int __attribute__((noinline)) |
| 34 |
bar_2 (int l, int w1, int w2, int useless, int useless2) |
| 35 |
{ |
| 36 |
return foo (l, w1, w2, useless2 + 5, useless); |
| 37 |
} |
| 38 |
|
| 39 |
static int __attribute__((noinline)) |
| 40 |
baz_2 (int useless, int useless2, int l, int w1, int w2) |
| 41 |
{ |
| 42 |
return bar_2 (l, w1, w2, useless, useless2); |
| 43 |
} |
| 44 |
|
| 45 |
|
| 46 |
static int __attribute__((noinline)) |
| 47 |
bax_2 (int l, int w1, int w2, int useless, int useless2) |
| 48 |
{ |
| 49 |
return work_2 (w2) + baz_2 (useless, useless2, l, w1, w2); |
| 50 |
} |
| 51 |
|
| 52 |
|
| 53 |
static int __attribute__((noinline)) |
| 54 |
foo (int l, int w1, int w2, int useless, int useless2) |
| 55 |
{ |
| 56 |
int r = 0; |
| 57 |
if (!l) |
| 58 |
return r; |
| 59 |
if (l % 2) |
| 60 |
r = bax_1 (l - 1, w1, w2, useless, useless2); |
| 61 |
else |
| 62 |
r = bax_2 (l - 1, w1, w2, useless, useless2); |
| 63 |
|
| 64 |
return r; |
| 65 |
} |
| 66 |
|
| 67 |
int |
| 68 |
entry (int l, int w1, int w2, int noneed, int noneed2) |
| 69 |
{ |
| 70 |
return foo (l, w2, w2, noneed2, noneed2 + 4); |
| 71 |
} |
| 72 |
|
| 73 |
/* { dg-final { scan-ipa-dump-times "Will remove parameter" 14 "sra" } } */ |
| 74 |
/* { dg-final { scan-tree-dump-not "useless" "optimized"} } */ |