| 1 |
/* Test LOOP generation for do while. |
| 2 |
Ensure the post-condition "do while" is correctly translated |
| 3 |
to a pre-condition PRU LOOP instruction. */ |
| 4 |
|
| 5 |
/* { dg-do run } */ |
| 6 |
/* { dg-options "-O1 -mloop" } */ |
| 7 |
|
| 8 |
/* -O1 in the options is significant. Without it do-loop will not be |
| 9 |
run. */ |
| 10 |
|
| 11 |
extern void abort (void); |
| 12 |
|
| 13 |
volatile unsigned int int_12345 = 12345; |
| 14 |
volatile unsigned int int_0 = 0; |
| 15 |
volatile unsigned int int_1 = 1; |
| 16 |
|
| 17 |
unsigned int |
| 18 |
test_loop (unsigned int n) |
| 19 |
{ |
| 20 |
unsigned int i = 0; |
| 21 |
volatile unsigned int s = 0; |
| 22 |
|
| 23 |
if (n >= 0x7fff) return 0; |
| 24 |
|
| 25 |
do { |
| 26 |
s++; |
| 27 |
i++; |
| 28 |
} while (i < n); |
| 29 |
return s; |
| 30 |
} |
| 31 |
|
| 32 |
|
| 33 |
int |
| 34 |
main (int argc, char** argv) |
| 35 |
{ |
| 36 |
if (test_loop (int_0) != 1) |
| 37 |
abort(); |
| 38 |
if (test_loop (int_1) != 1) |
| 39 |
abort(); |
| 40 |
if (test_loop (int_12345) != 12345) |
| 41 |
abort(); |
| 42 |
|
| 43 |
return 0; |
| 44 |
} |
| 45 |
|