| 1 |
/* { dg-do compile } */ |
| 2 |
/* { dg-options "-O2 -mabi=call0" } */ |
| 3 |
|
| 4 |
extern void foo(void); |
| 5 |
|
| 6 |
/* eliminated one register (the reservoir of variable 'a') by its stack slot through the stack pointer. */ |
| 7 |
int test0(int a) { |
| 8 |
int array[252]; /* the maximum bound of non-large stack. */ |
| 9 |
foo(); |
| 10 |
asm volatile("" : : "m"(array)); |
| 11 |
return a; |
| 12 |
} |
| 13 |
|
| 14 |
/* cannot eliminate if large stack is needed, because the offset from TOS cannot fit into single L32I/S32I instruction. */ |
| 15 |
int test1(int a) { |
| 16 |
int array[10000]; /* requires large stack. */ |
| 17 |
foo(); |
| 18 |
asm volatile("" : : "m"(array)); |
| 19 |
return a; |
| 20 |
} |
| 21 |
|
| 22 |
/* register A15 is the reservoir of the stack pointer and cannot be eliminated if the frame pointer is needed. |
| 23 |
other registers still can be, but through the frame pointer rather the stack pointer. */ |
| 24 |
int test2(int a) { |
| 25 |
int* p = __builtin_alloca(16); |
| 26 |
foo(); |
| 27 |
asm volatile("" : : "r"(p)); |
| 28 |
return a; |
| 29 |
} |
| 30 |
|
| 31 |
/* in -O0 the composite hard registers may still remain unsplitted at pro_and_epilogue and must be excluded. */ |
| 32 |
extern double bar(void); |
| 33 |
int __attribute__((optimize(0))) test3(int a) { |
| 34 |
return bar() + a; |
| 35 |
} |
| 36 |
|
| 37 |
/* { dg-final { scan-assembler-times "mov\t|mov.n\t" 21 } } */ |
| 38 |
/* { dg-final { scan-assembler-times "a15, 8" 2 } } */ |