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

--- Comment #2 from prathamesh3492 at gcc dot gnu.org ---
AFAIU, the underlying issue doesn't seem particular to float. For example,
there's a similar missed optimization with divmod transform:

unsigned f(unsigned x, unsigned y, unsigned a, unsigned b)
{
  if (a == b)
    {
      unsigned t1 = (a * x) / y;
      unsigned t2 = (b * x) % y;
      return t1 + t2;
    }
  return 0;
}

With -O2, optimized dump shows:

f (unsigned int x, unsigned int y, unsigned int a, unsigned int b)
{
  unsigned int t2;
  unsigned int t1;
  unsigned int _1;
  unsigned int _2;
  unsigned int _3;
  unsigned int _10;

  <bb 2> [local count: 1073741825]:
  if (a_4(D) == b_5(D))
    goto <bb 3>; [20.97%]
  else
    goto <bb 4>; [79.03%]

  <bb 3> [local count: 225163661]:
  _1 = a_4(D) * x_6(D);
  t1_8 = _1 / y_7(D);
  _2 = b_5(D) * x_6(D);
  t2_9 = _2 % y_7(D);
  _10 = t1_8 + t2_9;

  <bb 4> [local count: 1073741825]:
  # _3 = PHI <_10(3), 0(2)>
  return _3;

}

I assume the divmod transform would be applicable in this case ?

Thanks,
Prathamesh

Reply via email to