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

--- Comment #3 from Andrew Macleod <amacleod at redhat dot com> ---
EVRP figures out the j value can only be 0 or -9 and removes a few stmts as a
result, and simplifies the PHI, producing

  <bb 7> [local count: 114863530]:
  # j_12 = PHI <0(2), -9(6)>

  <bb 8> [local count: 1073741824]:
  # j_11 = PHI <j_12(7), -9(12)>
  if (j_11 != -9)
    goto <bb 3>; [94.50%]
  else
    goto <bb 9>; [5.50%]

which when we get to cunolli , looks like a loop and it does nothing.

When EVRP doesn't reduce the range from [-9, 0], we are instead left with:
  <bb 8> :
  # j_16 = PHI <0(2), _35(7)>
  if (j_16 != -9)
    goto <bb 3>; [INV]
  else
    goto <bb 9>; [INV]

After DSE, we have:
<bb 6> :
  *_8 = 0;

  <bb 8> : 
  # j_16 = PHI <0(2), -9(6), -9(5)>
  if (j_16 != -9)
    goto <bb 3>; [INV]
  else
    goto <bb 9>; [INV]

and the  CDDCE comes along and that turns into:
<bb 6> :
  *_8 = 0;

  <bb 7> :
  # j_17 = PHI <0(2), -9(6)>

  <bb 8> :
  # j_16 = PHI <j_17(7), -9(5)>
  if (j_16 != -9)
    goto <bb 3>; [INV]
  else
    goto <bb 9>; [INV]

Which is what eventually causes our problem, and this ends up looking like
another loop to cunrolli, and it does no analysis of it other than to mark it
as a 3rd loop.   And we never actually get rid of this.

IN the original version, cunroll analysis the loop and turns it into something
useful, without the extra phi..

If we dont do ccdce, then the same transformation shows up after switchconv in
profile_estimate..

So IM guessing this is a CFG "cleanup".

So EVRP cleans up the code, but it appears that it confuses cunrolli into
thinking there is nothing to do?

Reply via email to