Merge from mainline.
[official-gcc.git] / gcc / testsuite / gcc.dg / tree-ssa / loop-4.c
bloba6c8c8fd34a1ac4beaf1d931945311f7ace72d5d
1 /* A test for strength reduction and induction variable elimination. */
3 /* { dg-do compile } */
4 /* { dg-options "-O1 -fdump-tree-optimized" } */
5 /* { dg-require-effective-target size32plus } */
7 /* Size of this structure should be sufficiently weird so that no memory
8 addressing mode applies. */
10 struct bla
12 char x[187];
13 int y;
14 char z[253];
15 } arr_base[100];
17 int foo(void);
19 void xxx(void)
21 int iter;
23 for (iter = 0; iter < 100; iter++)
24 arr_base[iter].y = foo ();
27 /* Access to arr_base[iter].y should be strength reduced. Depending on
28 whether we have an addressing mode of type [base + offset], one of the
29 following forms might get chosen:
31 -- induction variable with base &arr_base[0].y, the memory access of
32 form *iv = ...
33 -- induction variable with base 0, the memory access of form
34 *(iv + &arr_base[0].y) = ...
36 In any case, we should not have any multiplication. */
38 /* { dg-final { scan-tree-dump-times " \\* \[^\\n\\r\]*=" 0 "optimized" } } */
39 /* { dg-final { scan-tree-dump-times "\[^\\n\\r\]*= \\* " 0 "optimized" } } */
40 /* { dg-final { scan-tree-dump-times "MEM" 1 "optimized" } } */
42 /* And the original induction variable should be eliminated. */
44 /* { dg-final { scan-tree-dump-times "iter" 0 "optimized" } } */
46 /* { dg-final { cleanup-tree-dump "optimized" } } */