| 1 |
/* { dg-do compile } */ |
| 2 |
/* { dg-options "-O2 -fdump-tree-vrp1" } */ |
| 3 |
|
| 4 |
// Define this to see it work. |
| 5 |
// #define WORK_WORK_WORK |
| 6 |
|
| 7 |
#define THIRD |
| 8 |
|
| 9 |
#ifdef THIRD |
| 10 |
#define FIRST i < 0 || |
| 11 |
#define ORIG int |
| 12 |
#define CAST |
| 13 |
#else |
| 14 |
|
| 15 |
#define FIRST |
| 16 |
#ifdef WORK_WORK_WORK |
| 17 |
#define ORIG unsigned int |
| 18 |
#define CAST |
| 19 |
#else |
| 20 |
#define ORIG int |
| 21 |
#define CAST (unsigned) |
| 22 |
#endif // WORK_WORK_WORK |
| 23 |
|
| 24 |
#endif // THIRD |
| 25 |
|
| 26 |
struct array |
| 27 |
{ |
| 28 |
const ORIG len; |
| 29 |
int *data; |
| 30 |
}; |
| 31 |
|
| 32 |
extern void call (ORIG); |
| 33 |
|
| 34 |
void doit (array *a) |
| 35 |
{ |
| 36 |
for (ORIG i = 0; i < a->len; ++i) |
| 37 |
{ |
| 38 |
if (FIRST CAST i >= CAST (a->len)) |
| 39 |
throw 5; |
| 40 |
call (a->data[i]); |
| 41 |
} |
| 42 |
} |
| 43 |
|
| 44 |
/* VRP should remove all but 1 if() in the loop. */ |
| 45 |
|
| 46 |
/* { dg-final { scan-tree-dump-times "if " 1 "vrp1"} } */ |