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

Andrew Pinski <pinskia at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
   Last reconfirmed|                            |2022-07-01
           Keywords|                            |missed-optimization
             Status|UNCONFIRMED                 |NEW
   Target Milestone|---                         |12.2
     Ever confirmed|0                           |1

--- Comment #2 from Andrew Pinski <pinskia at gcc dot gnu.org> ---

init_from_control_deps {{0 -> 3}}:
        i_44 != 2 (expanded)
        NOT (i_44 == 2)
After normalization [DEF]:
        i_44 != 2 (expanded)
        NOT (i_44 == 2)
After normalization [USE]:
        f2 (emax_8);
  is conditional on:
        ivtmp.7_37 == 2 (expanded)
        ivtmp.7_37 == 2

Which is funny we get:

  # ivtmp.7_37 = PHI <ivtmp.7_38(9), 0(2)>
  i_44 = (int) ivtmp.7_37;
  if (i_44 == 2)
    goto <bb 4>; [12.49%]
  else
    goto <bb 10>; [87.51%]
....
  if (ivtmp.7_37 == 2)
    goto <bb 8>; [12.49%]
  else
    goto <bb 9>; [87.51%]

  <bb 8> [local count: 268435456]:
  f2 (emax_8);

I don't know why ivopts only changed the second if and not the first.

Oh because the second is the exit check:
Replacing exit test: if (ivtmp_39 != 0)
Replacing exit test: if (i_40 == 2)

If we change the size to 4 and keep the 2 as 2, there would be no warning.
And if then change 2 to 3, the warning is back.

So there is a missed optimization of changing the internal comparison for the
IV to the new type if the right side is a constant.

Reply via email to