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

--- Comment #10 from Richard Biener <rguenth at gcc dot gnu.org> ---
The issue for FRE is that we have

  <bb 2> [local count: 10737416]:
  step.val = 610334368;
  value.val = 1;
  goto <bb 6>; [100.00%]

  <bb 6> [local count: 1073741824]:
  # __1 = PHI <0(2), __11(4)>
  if (__1 != 100)
    goto <bb 3>; [99.00%]
  else
    goto <bb 7>; [1.00%]

  <bb 3> [local count: 1063004409]:
  __builtin_printf ("%d %d\n", 1, 610334368);
  m = step;
  _12 = m.val;
  _13 = __builtin_constant_p (_12);
  if (_13 != 0)
    goto <bb 4>; [100.00%]
  else
    goto <bb 5>; [0.00%]

  <bb 4> [local count: 1063004409]:
  __builtin_puts (&"normal"[0]);
  m ={v} {CLOBBER(eol)};
  __builtin_printf ("%d %d\n", 1, 610334368);
  __11 = __1 + 1;
  goto <bb 6>; [100.00%]

  <bb 5> [count: 0]:
  __builtin_unreachable ();

and while the first FRE iteration correctly determines that m.val is 610334368
we then make the backedge of the loop executable and because we translated
the lookup expression from m.val to step.val we are refusing to handle loops
(the abort_on_visited argument to get_continuation_for_phi, set from
translated in walk_non_aliased_vuses).

I don't remember why I disregarded the fix in comment#3 of PR54498, a fix
along that line would enable CSE here.  The concern was probably
compile-time (but we limit the amount of alias queries done).

It's a bit late to do such change for GCC 12 I think.  I will queue this
for GCC 13.

Reply via email to