| 1 |
/* { dg-do compile } */ |
| 2 |
/* { dg-options "-O2 -fno-tree-vrp -std=c++11 -fno-strict-aliasing -fdump-tree-dom2" } */ |
| 3 |
|
| 4 |
#include <stdio.h> |
| 5 |
struct Field { |
| 6 |
virtual int Compare(void*, void*); |
| 7 |
}; |
| 8 |
extern int NKF, NR; |
| 9 |
extern int idxs[]; |
| 10 |
extern Field* the_field; |
| 11 |
extern int *incs; |
| 12 |
extern char** fptrs; |
| 13 |
inline int doCmp(int this_row_offset, int field_idx) { |
| 14 |
void *p = fptrs[field_idx] + this_row_offset * incs[field_idx]; |
| 15 |
return the_field->Compare(p,0); |
| 16 |
} |
| 17 |
bool Test(void) { |
| 18 |
|
| 19 |
int row_offset = 0; |
| 20 |
|
| 21 |
for (; row_offset < NR; ++row_offset) { |
| 22 |
|
| 23 |
bool is_different = false; |
| 24 |
for (int j = 0; j < NKF ; ++j) { |
| 25 |
int field_idx = idxs[j]; |
| 26 |
int cmp = doCmp(row_offset, field_idx); |
| 27 |
fprintf (stderr, "cmp=%d\n",cmp); |
| 28 |
|
| 29 |
if (cmp == 0) { |
| 30 |
continue; |
| 31 |
} |
| 32 |
if (cmp > 0) { |
| 33 |
is_different = true; |
| 34 |
break; |
| 35 |
} else { |
| 36 |
fprintf (stderr, "Incorrect\n"); |
| 37 |
return false; |
| 38 |
} |
| 39 |
} |
| 40 |
if (!is_different) { |
| 41 |
|
| 42 |
return false; |
| 43 |
} |
| 44 |
} |
| 45 |
|
| 46 |
return true; |
| 47 |
} |
| 48 |
|
| 49 |
// The block ending with cmp == 0 should not be threaded. ie, |
| 50 |
// there should be a single == 0 comparison in the dump file. |
| 51 |
|
| 52 |
// { dg-final { scan-tree-dump-times "== 0" 1 "dom2" } } |