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

--- Comment #3 from Jakub Jelinek <jakub at gcc dot gnu.org> ---
The r9-2635 change miscompiles it during PRE,
  <bb 2> [local count: 347387062]:
  j_7 ={v} s;
  if (j_7 == 0)
    goto <bb 3>; [34.00%]
  else
    goto <bb 6>; [66.00%]

  <bb 3> [local count: 291805133]:
  # i_8 = PHI <0(2), i_2(6)>

  <bb 4> [local count: 1073741825]:
  foo ();
  if (j_7 == 0)
    goto <bb 8>; [89.00%]
  else
    goto <bb 5>; [11.00%]

  <bb 8> [local count: 955630225]:
  goto <bb 4>; [100.00%]

  <bb 5> [local count: 118111601]:
  i_10 = i_8 + 1;

  <bb 6> [local count: 347387062]:
  # i_2 = PHI <i_10(5), 0(2)>
  if (i_2 < j_7)
    goto <bb 3>; [50.00%]
  else
    goto <bb 7>; [50.00%]

  <bb 7> [local count: 173693531]:
  return 0;
looks ok, but PRE assumes the second j_7 == 0 is always true and thus turns the
foo () call into a tight endless loop:
  <bb 4> [local count: 1073741825]:
  foo ();
  goto <bb 4>; [100.00%]
That is the intention of the testcase when s == 0, but not otherwise.

Reply via email to