aboutsummaryrefslogtreecommitdiffstats
path: root/gcc-4.9/gcc/testsuite/g++.dg/tree-ssa/pr61009.C
blob: 4e7bb1a1c7b8807c04d9e6ae0282932874647b82 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
/* { dg-do compile } */
/* { dg-options "-O2 -fno-tree-vrp -std=c++11 -fno-strict-aliasing -fdump-tree-dom1" } */

#include <stdio.h>
struct Field {
 virtual int Compare(void*, void*);
};
extern int NKF, NR;
extern int idxs[];
extern Field* the_field;
extern int *incs;
extern char** fptrs;
inline int doCmp(int this_row_offset, int field_idx) {
 void *p = fptrs[field_idx] + this_row_offset * incs[field_idx];
 return the_field->Compare(p,0);
}
bool  Test(void) {

 int row_offset = 0;

 for (; row_offset < NR; ++row_offset) {

   bool is_different = false;
   for (int j = 0; j < NKF ; ++j) {
     int field_idx = idxs[j];
     int cmp = doCmp(row_offset, field_idx);
     fprintf (stderr, "cmp=%d\n",cmp);

     if (cmp == 0) {
       continue;
     }
     if (cmp > 0) {
       is_different = true;
       break;
     } else {
       fprintf (stderr, "Incorrect\n");
       return false;
     }
   }
   if (!is_different) {

     return false;
   }
 }

 return true;
}

// The block ending with cmp == 0 should not be threaded.  ie,
// there should be a single == 0 comparison in the dump file.

// { dg-final { scan-tree-dump-times "== 0" 1 "dom1" } }
// { dg-final { cleanup-tree-dump "dom1" } }