| 1 |
/* PR optimization/11536 */ |
| 2 |
/* { dg-do run } */ |
| 3 |
/* { dg-options "-O2" } */ |
| 4 |
/* Origin: [email protected] <[email protected]> */ |
| 5 |
/* Testcase by Andrew Pinski <[email protected]> */ |
| 6 |
|
| 7 |
/* Verify that the loop optimizer doesn't use moving targets |
| 8 |
to calculate the number of iterations of a loop. */ |
| 9 |
|
| 10 |
extern void abort(void); |
| 11 |
|
| 12 |
void foo(int) __attribute__((__noinline__)); |
| 13 |
|
| 14 |
void foo(int i) |
| 15 |
{ |
| 16 |
abort(); |
| 17 |
} |
| 18 |
|
| 19 |
int main() |
| 20 |
{ |
| 21 |
int i; |
| 22 |
int first= 0; |
| 23 |
int last= 0; |
| 24 |
|
| 25 |
while (last<3) { |
| 26 |
last = first; |
| 27 |
|
| 28 |
while (first<=last) { |
| 29 |
first++; |
| 30 |
|
| 31 |
for (i=0;i<3;i++) |
| 32 |
last++; |
| 33 |
|
| 34 |
if (last>10) |
| 35 |
return 0; |
| 36 |
} |
| 37 |
|
| 38 |
foo(first); |
| 39 |
} |
| 40 |
|
| 41 |
return 0; |
| 42 |
} |