| 1 |
/* A test for strength reduction and induction variable elimination. */ |
| 2 |
|
| 3 |
/* { dg-do compile } */ |
| 4 |
/* { dg-options "-O1 -fdump-tree-optimized" } */ |
| 5 |
/* { dg-require-effective-target size32plus } */ |
| 6 |
|
| 7 |
/* Size of this structure should be sufficiently weird so that no memory |
| 8 |
addressing mode applies. */ |
| 9 |
|
| 10 |
struct bla |
| 11 |
{ |
| 12 |
char x[187]; |
| 13 |
int y; |
| 14 |
char z[253]; |
| 15 |
} arr_base[100]; |
| 16 |
|
| 17 |
int foo(void); |
| 18 |
|
| 19 |
void xxx(void) |
| 20 |
{ |
| 21 |
int iter; |
| 22 |
|
| 23 |
for (iter = 0; iter < 100; iter++) |
| 24 |
arr_base[iter].y = foo (); |
| 25 |
} |
| 26 |
|
| 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: |
| 30 |
|
| 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) = ... |
| 35 |
|
| 36 |
In any case, we should not have any multiplication. */ |
| 37 |
|
| 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" } } */ |
| 41 |
|
| 42 |
/* And the original induction variable should be eliminated. */ |
| 43 |
|
| 44 |
/* { dg-final { scan-tree-dump-times "iter" 0 "optimized" } } */ |
| 45 |
|