| 1 |
/* { dg-do compile } */ |
| 2 |
/* { dg-options "-O2 -fno-stack-protector" } */ |
| 3 |
|
| 4 |
/* Test reuse of stack adjustment temporaries. */ |
| 5 |
|
| 6 |
void foo (); |
| 7 |
|
| 8 |
/* Should only use 1 mov and re-use it. */ |
| 9 |
int reuse_mov (int i) |
| 10 |
{ |
| 11 |
int arr[1025]; |
| 12 |
return arr[i]; |
| 13 |
} |
| 14 |
|
| 15 |
/* Should use 2 movs because x12 is live. */ |
| 16 |
int no_reuse_mov_live (int i) |
| 17 |
{ |
| 18 |
int arr[1025]; |
| 19 |
register long long a __asm("x12"); |
| 20 |
a = a+1; |
| 21 |
return arr[i] + a; |
| 22 |
} |
| 23 |
|
| 24 |
/* Should use 2 movs because its not a leaf function. */ |
| 25 |
int no_reuse_mov (int i) |
| 26 |
{ |
| 27 |
int arr[1025]; |
| 28 |
foo (); |
| 29 |
return arr[i]; |
| 30 |
} |
| 31 |
|
| 32 |
/* { dg-final { scan-assembler-times "mov\tx12, \[0-9\]+" 5 } } */ |