| 1 |
/* { dg-do compile { target c++11 } } */ |
| 2 |
/* { dg-options "-O3 -fdump-tree-optimized" } */ |
| 3 |
|
| 4 |
typedef int Items[2]; |
| 5 |
|
| 6 |
struct ItemArray |
| 7 |
{ |
| 8 |
Items items; |
| 9 |
int sum_x2() const; |
| 10 |
}; |
| 11 |
|
| 12 |
int ItemArray::sum_x2() const |
| 13 |
{ |
| 14 |
int total = 0; |
| 15 |
for (int item : items) |
| 16 |
{ |
| 17 |
total += item; |
| 18 |
} |
| 19 |
return total; |
| 20 |
} |
| 21 |
|
| 22 |
/* We should be able to compute the number of iterations to two, unroll |
| 23 |
the loop and end up with a single basic-block in sum_x2. */ |
| 24 |
/* { dg-final { scan-tree-dump-times "bb" 1 "optimized" } } */ |