| 1 |
/* { dg-do compile } */ |
| 2 |
/* { dg-options "-O2 -fipa-ra -fomit-frame-pointer -fno-optimize-sibling-calls" } */ |
| 3 |
/* { dg-additional-options "-mregparm=1" { target ia32 } } */ |
| 4 |
|
| 5 |
/* Test -fipa-ra optimization on self-recursive function. */ |
| 6 |
|
| 7 |
static int __attribute__((noinline)) |
| 8 |
bar (int x) |
| 9 |
{ |
| 10 |
if (x > 4) |
| 11 |
return bar (x - 3); |
| 12 |
return 0; |
| 13 |
} |
| 14 |
|
| 15 |
int __attribute__((noinline)) |
| 16 |
foo (int y) |
| 17 |
{ |
| 18 |
return y + bar (y); |
| 19 |
} |
| 20 |
|
| 21 |
/* Check that no registers are saved/restored. */ |
| 22 |
/* { dg-final { scan-assembler-not "push" } } */ |
| 23 |
/* { dg-final { scan-assembler-not "pop" } } */ |
| 24 |
|
| 25 |
/* Check that addition uses dx. */ |
| 26 |
/* { dg-final { scan-assembler-times "addl\t%\[re\]?dx, %\[re\]?ax" 1 } } */ |
| 27 |
|
| 28 |
/* Verify that bar is self-recursive. */ |
| 29 |
/* { dg-final { scan-assembler-times "call\t_?bar" 2 } } */ |