| 1 |
// { dg-do run } |
| 2 |
// PR tree-optimization/116120 |
| 3 |
|
| 4 |
// The optimization for `(a ? x : y) != (b ? x : y)` |
| 5 |
// missed that x and y could be the same value. |
| 6 |
|
| 7 |
typedef int v4si __attribute((__vector_size__(1 * sizeof(int)))); |
| 8 |
v4si f1(v4si a, v4si b, v4si c, v4si d, v4si e, v4si f) { |
| 9 |
v4si X = a == b ? e : f; |
| 10 |
v4si Y = c == d ? e : f; |
| 11 |
return (X != Y); // ~(X == Y ? -1 : 0) (x ^ Y) |
| 12 |
} |
| 13 |
|
| 14 |
int f2(int a, int b, int c, int d, int e, int f) { |
| 15 |
int X = a == b ? e : f; |
| 16 |
int Y = c == d ? e : f; |
| 17 |
return (X != Y) ? -1 : 0; // ~(X == Y ? -1 : 0) (x ^ Y) |
| 18 |
} |
| 19 |
|
| 20 |
int main() |
| 21 |
{ |
| 22 |
v4si a = {0}; |
| 23 |
v4si b = {0}; // a == b, true |
| 24 |
v4si c = {2}; |
| 25 |
v4si d = {3}; // c == b, false |
| 26 |
v4si e = {0}; |
| 27 |
v4si f = e; |
| 28 |
v4si r = f1(a,b,c,d,e, f); |
| 29 |
int r1 = f2(a[0], b[0], c[0], d[0], e[0], f[0]); |
| 30 |
if (r[0] != r1) |
| 31 |
__builtin_abort(); |
| 32 |
} |