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

--- Comment #4 from Richard Biener <rguenth at gcc dot gnu.org> ---
When doing partial PRE we somehow lose the effect of

  g = 1;

we also generate weird PHIs:

<bb 2>
  pretmp_20 = h;
  pretmp_22 = g; 


<bb 3>
  # prephitmp_21 = PHI <pretmp_20(2), prephitmp_25(10)>
  # prephitmp_23 = PHI <pretmp_22(2), prephitmp_24(10)>
  # prephitmp_24 = PHI <pretmp_22(2), prephitmp_24(10)>
  # prephitmp_25 = PHI <pretmp_20(2), prephitmp_25(10)>

those are all unnecessary ...

There's one old detail I never understood in partial ANTIC compute and that
gets us weird expressions in here, which is that we do not PHI translate
ANTIC_IN when computing PA_OUT.  Fixing that fixes this bug.

I have no idea how to create a testcase for the testsuite though besides
verifying we're not inserting any PHI - but we also fail to partial-PRE the
load
of h here, likely because of the iteration order imposed by the infinite
loop which is probably also key to the miscompilation.

Anyway, I have a fix, but I'm not 100% sure it fixes the actual cause.

Reply via email to