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

--- Comment #2 from Andrew Pinski <pinskia at gcc dot gnu.org> ---
Actually this is more complex, I had missed the original add too.
the full loop:
 <bb 3> [local count: 958878296]:
  _18 = (unsigned int) ivtmp.7_15;
  len_test_12 = _18 + 1;
  ivtmp.7_7 = ivtmp.7_15 + 1;
  if (ivtmp.7_7 != _21)
    goto <bb 7>; [94.50%]
  else
    goto <bb 9>; [5.50%]

  <bb 9> [local count: 52738306]:
  # len_test_17 = PHI <len_test_12(3)>
  goto <bb 5>; [100.00%]

  <bb 7> [local count: 906139990]:

  <bb 4> [local count: 1014686026]:
  # ivtmp.7_15 = PHI <ivtmp.7_7(7), 2(6)>
  _4 = (unsigned int) ivtmp.7_15;
  len_test_13 = _4;
  _3 = MEM[(const uint8_t *)buf_9(D) + ivtmp.7_15 * 1];
  _6 = MEM[(const uint8_t *)buf_back_11(D) + ivtmp.7_15 * 1];
  if (_3 == _6)
    goto <bb 3>; [94.50%]
  else
    goto <bb 10>; [5.50%]

  <bb 10> [local count: 55807731]:
  # len_test_16 = PHI <len_test_13(4)>

We can't just sink the cast though as that would violate the closed-loop-SSA.
We would need to sink also:
  _18 = (unsigned int) ivtmp.7_15;
  len_test_12 = _18 + 1;

Which we do at the RTL level ....

Reply via email to