| 1 |
/* { dg-do compile } */ |
| 2 |
/* -mlongcall will cause us to place &foo in the CTR register. */ |
| 3 |
/* { dg-skip-if "" { powerpc*-*-* } { "-mlongcall" } { "" } } */ |
| 4 |
/* { dg-options "-O1 -ftree-loop-ivcanon -funroll-loops -fdump-tree-ivcanon-details -fdump-tree-cunroll-details -fdump-tree-optimized" } */ |
| 5 |
/* { dg-options "-O1 -ftree-loop-ivcanon -funroll-loops -fdump-tree-ivcanon-details -fdump-tree-cunroll-details -fdump-tree-optimized -mshort-calls" {target epiphany-*-*} } */ |
| 6 |
|
| 7 |
|
| 8 |
/* On 31-bit S/390 the function address will be stored (once) in the literal pool, |
| 9 |
so scan-assembler-times "foo" will return 1 even if the loop is fully unrolled. |
| 10 |
-msmall-exec avoids this by enabling a call instruction with immediate operand. */ |
| 11 |
/* { dg-options "-O1 -ftree-loop-ivcanon -funroll-loops -fdump-tree-ivcanon-details -fdump-tree-cunroll-details -fdump-tree-optimized -msmall-exec" { target s390-*-* } } */ |
| 12 |
|
| 13 |
/* On Darwin, we call extern functions via a stub in PIC mode which is default and |
| 14 |
the stub is named after the function. To avoid this we use -static to go out |
| 15 |
of PIC mode. */ |
| 16 |
/* { dg-options "-O1 -ftree-loop-ivcanon -funroll-loops -fdump-tree-ivcanon-details -fdump-tree-cunroll-details -fdump-tree-optimized -static" { target *-*-darwin* } } */ |
| 17 |
|
| 18 |
/* On MIPS, disable generating hints (R_MIPS_JALR) for PIC calls. In addition |
| 19 |
to the load from the GOT this also contains the name of the function so for |
| 20 |
each call the function name would appear twice. */ |
| 21 |
/* { dg-options "-O1 -ftree-loop-ivcanon -funroll-loops -fdump-tree-ivcanon-details -fdump-tree-cunroll-details -fdump-tree-optimized -mno-relax-pic-calls" { target mips*-*-* } } */ |
| 22 |
__attribute__ ((pure)) |
| 23 |
int foo (int x); |
| 24 |
int xxx(void) |
| 25 |
{ |
| 26 |
int x = 45; |
| 27 |
int sum = 0; |
| 28 |
|
| 29 |
while (x >>= 1) |
| 30 |
sum += foo (x) * 2; |
| 31 |
return sum; |
| 32 |
} |
| 33 |
|
| 34 |
/* We should be able to find out that the loop iterates four times and unroll it completely. */ |
| 35 |
|
| 36 |
/* { dg-final { scan-tree-dump-times "Added canonical iv to loop 1, 4 iterations" 1 "ivcanon"} } */ |
| 37 |
/* { dg-final { scan-tree-dump-times "loop with 4 iterations completely unrolled" 1 "cunroll"} } */ |
| 38 |
/* { dg-final { scan-tree-dump-times "foo" 5 "optimized"} } */ |
| 39 |
|
| 40 |
/* Because hppa, ia64 and Windows targets include an external declaration |
| 41 |
for foo as well as the calls we need to look for something more specific |
| 42 |
than just foo in order to count only the calls and not the declaration. */ |
| 43 |
/* The SH targets always use separate instructions to load the address |
| 44 |
and to do the actual call - bsr is only generated by link time |
| 45 |
relaxation. */ |
| 46 |
/* MSP430 keeps the address in a register. */ |
| 47 |
/* m68k sometimes puts the address in a register, depending on CPU and PIC. */ |
| 48 |
|
| 49 |
/* { dg-final { scan-assembler-times "foo" 5 { xfail hppa*-*-* ia64*-*-* sh*-*-* fido-*-* m68k-*-* i?86-*-mingw* i?86-*-cygwin* x86_64-*-mingw* visium-*-* nvptx*-*-* pdp11*-*-* msp430-*-* amdgcn*-*-* } } } */ |
| 50 |
/* { dg-final { scan-assembler-times "foo,%r" 5 { target hppa*-*-* } } } */ |
| 51 |
/* { dg-final { scan-assembler-times "= foo" 5 { target ia64*-*-* } } } */ |
| 52 |
/* { dg-final { scan-assembler-times "call\[ \t\]*_foo" 5 { target i?86-*-mingw* i?86-*-cygwin* } } } */ |
| 53 |
/* { dg-final { scan-assembler-times "call\[ \t\]*foo" 5 { target x86_64-*-mingw* } } } */ |
| 54 |
/* { dg-final { scan-assembler-times "jsr|bsrf|blink\ttr?,r18" 5 { target sh*-*-* } } } */ |
| 55 |
/* { dg-final { scan-assembler-times "\[jb\]sr" 5 { target fido-*-* m68k-*-* pdp11-*-* } } } */ |
| 56 |
/* { dg-final { scan-assembler-times "bra *tr,r\[1-9\]*,r21" 5 { target visium-*-* } } } */ |
| 57 |
/* { dg-final { scan-assembler-times "(?n)\[ \t\]call\[ \t\].*\[ \t\]foo," 5 { target nvptx*-*-* } } } */ |
| 58 |
/* { dg-final { scan-assembler-times "s_swappc_b64" 5 { target { amdgcn*-*-* } } } } */ |