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

Richard Biener <rguenth at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|UNCONFIRMED                 |NEW
     Ever confirmed|0                           |1
   Last reconfirmed|                            |2021-08-20

--- Comment #1 from Richard Biener <rguenth at gcc dot gnu.org> ---
  <bb 3> [local count: 955630225]:
  # r_11 = PHI <r_8(6), d_3(D)(5)>
  r_8 = e_7(D) & r_11;

I wonder if this is sth for phiopt to pattern match.  In principle VN
would need to figure (for PRE) that the PHI translated d_3(D) & e_7(D)
is equal to r_8.  So the "trick" (aka pattern-matching) could be done
during phi_translation.

But then both look like a hack.  Curiously when we do

int f(int t, int d, int e)
{
  int r = d & e;
  for(int i = 0; i < t; i++)
    r &= e;
  return r;
}

aka "peel" one iteration, then CCP is what eliminates the in-loop AND.
Ah, that's because we simplify d & e & e since we optimistically start
with just the entry edge value.  And that remains so.  With PRE
we're not fully re-doing VN of PHIs but phi-translation seeks to
re-use existing value-numbers where possible, so a programmatic approach
doesn't work here.

Reply via email to