| 1 |
/* { dg-do compile } */ |
| 2 |
/* { dg-options "-O2 -fipa-ra -fomit-frame-pointer" } */ |
| 3 |
/* { dg-additional-options "-mregparm=1" { target ia32 } } */ |
| 4 |
|
| 5 |
/* Testing -fipa-ra optimization option. */ |
| 6 |
|
| 7 |
static int __attribute__((noinline)) |
| 8 |
bar (int x) |
| 9 |
{ |
| 10 |
return x + 3; |
| 11 |
} |
| 12 |
|
| 13 |
int __attribute__((noinline)) |
| 14 |
foo (int y) |
| 15 |
{ |
| 16 |
return y + bar (y); |
| 17 |
} |
| 18 |
|
| 19 |
/* Check that no registers are saved/restored. */ |
| 20 |
/* { dg-final { scan-assembler-not "push" } } */ |
| 21 |
/* { dg-final { scan-assembler-not "pop" } } */ |
| 22 |
|
| 23 |
/* PR61605. If the first argument register and the return register differ, then |
| 24 |
bar leaves the first argument register intact. That means in foo that the |
| 25 |
first argument register still contains y after bar has been called, and |
| 26 |
there's no need to copy y to a different register before the call, to be able |
| 27 |
to use it after the call. |
| 28 |
Check that the copy is absent. */ |
| 29 |
/* { dg-final { scan-assembler-not "movl" { target { ! ia32 } } } } */ |
| 30 |
|
| 31 |
/* Check that addition uses di (in case of no copy) or dx (in case of copy). */ |
| 32 |
/* { dg-final { scan-assembler-times "addl\t%\[re\]?d\[ix\], %\[re\]?ax" 1 } } */ |