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

--- Comment #3 from Andrew Pinski <pinskia at gcc dot gnu.org> ---
Here is another testcase which should produce the same code:
int f3(int i, int j, int l)
{
  int t = i | j;
  _Bool t1 = l != 0;
  _Bool t2 = t ? 1 : t1;
  return t2;
}

int f4(int i, int j, int l)
{
  int t = i | j;
  _Bool t1 = l != 0;
  _Bool t2;
  if (t)
   t2 = 1;
  else
   t2 = t1;
  return t2;
}


--- CUT ----
Note f1, f2, f3 and f4 all produce the same code now.
f comes close now, but still requires work:
        orr     w0, w0, w1
        cmp     w0, 0
        cset    w0, ne
        cmp     w2, 0
        csinc   w0, w0, wzr, eq
it does an ifcvt on the rtl level to get the csinc.
f4 is exactly what f2 looks like at the .optimized as the input to the gimple
and reassoc can optimize this case but only if we sink l != 0 into the if
statement.

So this is another improvement needed for reassoc really.
I will look at this next week or the week after.

Reply via email to