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

Jakub Jelinek <jakub at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |ams at gcc dot gnu.org,
                   |                            |jakub at gcc dot gnu.org

--- Comment #7 from Jakub Jelinek <jakub at gcc dot gnu.org> ---
I think this is just a bogus warning introduced in r217891, the generated code
looks ok.
Code like:
  <bb 5>:
  # f_27 = PHI <f_23(4), f_17(8)>
  if (f_27 != 0)
    goto <bb 6>;
  else
    goto <bb 7>;

  <bb 6>:
  _11 = f_27 + -1;
  iftmp.0_12 = A[_11];
  if (f_27 != 7)
    goto <bb 7>;
  else
    goto <bb 8>;

  <bb 7>:
  # iftmp.0_28 = PHI <iftmp.0_12(6), 0(5)>
  _13 = f_27 + 1;
  iftmp.1_14 = A[_13];

  <bb 8>:
  # iftmp.1_4 = PHI <iftmp.1_14(7), 0(6)>
  # iftmp.0_29 = PHI <iftmp.0_28(7), iftmp.0_12(6)>
  _15 = iftmp.0_29 | iftmp.1_4;
  B[f_27] = _15;
  f_17 = f_27 + 1;
  if (f_17 == 8)
    goto <bb 9>;
  else
    goto <bb 5>;
is transformed by dom1 into an extra early exit from the loop, if f_27 == 7, we
jump to a new bb outside of the loop that does:
  <bb 11>:
  # iftmp.1_2 = PHI <0(6)>
  # iftmp.0_3 = PHI <iftmp.0_12(6)>
  _1 = iftmp.0_3 | iftmp.1_2;
  B[f_27] = _1;
  f_26 = f_27 + 1;
  goto <bb 10>;
But indeed dom nor anything else doesn't figure out that the f_17 == 8
exit condition of the loop is then never true, the loop will always exit
through the jump to bb 11.
Supposedly the warning needs to be limited to the case where the loop has only
a single exit, or when the undefined behavior occurs on all loop exits.

Reply via email to