Merge from mainline
[official-gcc.git] / gcc / testsuite / gcc.dg / tree-ssa / loop-1.c
blob3ae4819256ab2ac91a3f599bd525c08821b9d8b7
1 /* { dg-do compile } */
2 /* { dg-options "-O1 -ftree-loop-ivcanon -funroll-loops -fdump-tree-ivcanon-details -fdump-tree-cunroll-details -fdump-tree-optimized" } */
4 /* On 31-bit S/390 the function address will be stored (once) in the literal pool,
5 so scan-assembler-times "foo" will return 1 even if the loop is fully unrolled.
6 -msmall-exec avoids this by enabling a call instruction with immediate operand. */
7 /* { dg-options "-O1 -ftree-loop-ivcanon -funroll-loops -fdump-tree-ivcanon-details -fdump-tree-cunroll-details -fdump-tree-optimized -msmall-exec" { target s390-*-* } } */
9 /* On Darwin, we call extern functions via a stub in PIC mode which is default and
10 the stub is named after the function. To avoid this we use -static to go out
11 of PIC mode. */
12 /* { dg-options "-O1 -ftree-loop-ivcanon -funroll-loops -fdump-tree-ivcanon-details -fdump-tree-cunroll-details -fdump-tree-optimized -static" { target *-*-darwin* } } */
14 void xxx(void)
16 int x = 45;
18 while (x >>= 1)
19 foo ();
22 /* We should be able to find out that the loop iterates four times and unroll it completely. */
24 /* { dg-final { scan-tree-dump-times "Added canonical iv to loop 1, 4 iterations" 1 "ivcanon"} } */
25 /* { dg-final { cleanup-tree-dump "ivcanon" } } */
26 /* { dg-final { scan-tree-dump-times "Unrolled loop 1 completely" 1 "cunroll"} } */
27 /* { dg-final { cleanup-tree-dump "cunroll" } } */
28 /* { dg-final { scan-tree-dump-times "foo" 5 "optimized"} } */
29 /* { dg-final { cleanup-tree-dump "optimized" } } */
31 /* Because hppa and ia64 targets include an external declaration for foo as
32 well as the calls we need to look for something more specific then just
33 foo in order to count only the calls and not the declaration. */
34 /* The SH targets always use separate instructions to load the address
35 and to do the actual call - bsr is only generated by link time
36 relaxation. */
37 /* CRIS keeps the address in a register. */
38 /* m68k sometimes puts the address in a register, depending on CPU and PIC. */
40 /* { dg-final { scan-assembler-times "foo" 5 { xfail hppa*-*-* ia64*-*-* sh*-*-* cris-*-* m68k-*-* } } } */
41 /* { dg-final { scan-assembler-times "foo,%r" 5 { target hppa*-*-* } } } */
42 /* { dg-final { scan-assembler-times "= foo" 5 { target ia64*-*-* } } } */
43 /* { dg-final { scan-assembler-times "jsr|blink\ttr?,r18" 5 { target sh*-*-* } } } */
44 /* { dg-final { scan-assembler-times "Jsr \\\$r" 5 { target cris-*-* } } } */
45 /* { dg-final { scan-assembler-times "\[jb\]sr" 5 { target m68k-*-* } } } */