https://gcc.gnu.org/bugzilla/show_bug.cgi?id=116120

--- Comment #1 from Andrew Pinski <pinskia at gcc dot gnu.org> ---
testcase that shows the issue:
```
typedef int v4si __attribute((__vector_size__(1 * sizeof(int))));
v4si f1(v4si a, v4si b, v4si c, v4si d, v4si e, v4si f) {
  v4si X = a == b ? e : f;
  v4si Y = c == d ? e : f;
  return (X != Y); // ~(X == Y ? -1 : 0) (x ^ Y)
}

int f2(int a, int b, int c, int d, int e, int f) {
  int X = a == b ? e : f;
  int Y = c == d ? e : f;
  return (X != Y) ? -1 : 0; // ~(X == Y ? -1 : 0) (x ^ Y)
}

int main()
{
  v4si a = {0};
  v4si b = {0}; // a == b, true
  v4si c = {2};
  v4si d = {3}; // c == b, false
  v4si e = {0};
  v4si f = e;
  v4si r = f1(a,b,c,d,e, f);
  int r1 = f2(a[0], b[0], c[0], d[0], e[0], f[0]);
  if (r[0] != r1)
    __builtin_abort();
  __builtin_printf ("%d == %d.\n", r[0], r1);
}
```
So the test needs to add `(x == y)`/`(a != b)`

So it should be:
/* (a ? x : y) != (b ? x : y) --> (a^b & (x != y)) ? TRUE  : FALSE */
/* (a ? x : y) == (b ? x : y) --> (a^b & (x != y)) ? FALSE : TRUE  */

/* (a ? x : y) != (b ? y : x) --> (a^b | (x == y)) ? FALSE : TRUE  */
/* (a ? x : y) == (b ? y : x) --> (a^b | (x == y)) ? TRUE  : FALSE */

This was introduced when Eikansh tried to make this generic more than just -1/0
and it was missed that handled the case where `x == y`. Anyways I will fix
this.

Reply via email to