| 1 |
/* PR tree-optimization/111150 */ |
| 2 |
/* { dg-do compile } */ |
| 3 |
/* { dg-options "-O1 -fgimple -fdump-tree-forwprop1-raw" } */ |
| 4 |
|
| 5 |
/* Checks if pattern (X ? e : f) == (Y ? e : f) gets optimized. */ |
| 6 |
__GIMPLE() |
| 7 |
_Bool f1_(int a, int b, int c, int d, int e, int f) { |
| 8 |
_Bool X; |
| 9 |
_Bool Y; |
| 10 |
_Bool t; |
| 11 |
int t1; |
| 12 |
int t2; |
| 13 |
X = a == b; |
| 14 |
Y = c == d; |
| 15 |
/* Before the patch cond_expr was generated for these 2 statements. */ |
| 16 |
t1 = X ? e : f; |
| 17 |
t2 = Y ? e : f; |
| 18 |
t = t1 == t2; |
| 19 |
return t; |
| 20 |
} |
| 21 |
|
| 22 |
/* Checks if pattern (X ? e : f) != (Y ? e : f) gets optimized. */ |
| 23 |
__GIMPLE() |
| 24 |
_Bool f2_(int a, int b, int c, int d, int e, int f) { |
| 25 |
_Bool X; |
| 26 |
_Bool Y; |
| 27 |
_Bool t; |
| 28 |
int t1; |
| 29 |
int t2; |
| 30 |
X = a == b; |
| 31 |
Y = c == d; |
| 32 |
t1 = X ? e : f; |
| 33 |
t2 = Y ? e : f; |
| 34 |
t = t1 != t2; |
| 35 |
return t; |
| 36 |
} |
| 37 |
|
| 38 |
/* Checks if pattern (X ? e : f) == (Y ? f : e) gets optimized. */ |
| 39 |
__GIMPLE() |
| 40 |
_Bool f3_(int a, int b, int c, int d, int e, int f) { |
| 41 |
_Bool X; |
| 42 |
_Bool Y; |
| 43 |
_Bool t; |
| 44 |
int t1; |
| 45 |
int t2; |
| 46 |
X = a == b; |
| 47 |
Y = c == d; |
| 48 |
t1 = X ? e : f; |
| 49 |
t2 = Y ? f : e; |
| 50 |
t = t1 == t2; |
| 51 |
return t; |
| 52 |
} |
| 53 |
|
| 54 |
/* Checks if pattern (X ? e : f) != (Y ? f : e) gets optimized. */ |
| 55 |
__GIMPLE() |
| 56 |
_Bool f4_(int a, int b, int c, int d, int e, int f) { |
| 57 |
_Bool X; |
| 58 |
_Bool Y; |
| 59 |
_Bool t; |
| 60 |
int t1; |
| 61 |
int t2; |
| 62 |
X = a == b; |
| 63 |
Y = c == d; |
| 64 |
t1 = X ? e : f; |
| 65 |
t2 = Y ? f : e; |
| 66 |
t = t1 != t2; |
| 67 |
return t; |
| 68 |
} |
| 69 |
|
| 70 |
/* Should generate one bit_xor_expr for each testcase. */ |
| 71 |
/* { dg-final { scan-tree-dump-not "cond_expr, " "forwprop1" } } */ |
| 72 |
/* 2 IOR, one each for f1 and f2. |
| 73 |
2 AND, one each for f3 and f4. */ |
| 74 |
/* { dg-final { scan-tree-dump-times "bit_ior_expr, " 2 "forwprop1" } } */ |
| 75 |
/* { dg-final { scan-tree-dump-times "bit_and_expr, " 2 "forwprop1" } } */ |
| 76 |
/* { dg-final { scan-tree-dump-times "bit_xor_expr, " 4 "forwprop1" } } */ |
| 77 |
/* 8 eq comparisons from each of `a == b`/`c == d`. |
| 78 |
2 more to check that `e == f` |
| 79 |
2 ne comparisons to check that `e != f`. */ |
| 80 |
/* { dg-final { scan-tree-dump-times "<ne_expr, " 2 "forwprop1" } } */ |
| 81 |
/* { dg-final { scan-tree-dump-times "<eq_expr, " 10 "forwprop1" } } */ |