[llvm-bugs] [Bug 31867] New: InstCombine uselessly checks for irreducible phi cycles.

via llvm-bugs llvm-bugs at lists.llvm.org
Sat Feb 4 15:17:44 PST 2017


https://llvm.org/bugs/show_bug.cgi?id=31867

            Bug ID: 31867
           Summary: InstCombine uselessly checks for irreducible phi
                    cycles.
           Product: libraries
           Version: trunk
          Hardware: PC
                OS: All
            Status: NEW
          Severity: normal
          Priority: P
         Component: Scalar Optimizations
          Assignee: unassignedbugs at nondot.org
          Reporter: dberlin at dberlin.org
                CC: llvm-bugs at lists.llvm.org
    Classification: Unclassified

InstCombinePhi has this code:

   // We sometimes end up with phi cycles that non-obviously end up being the
   // same value, for example:
   //   z = some value; x = phi (y, z); y = phi (x, z)
   // where the phi nodes don't necessarily need to be in the same block.  Do a
   // quick check to see if the PHI node only contains a single non-phi value,
if
   // so, scan to see if the phi cycle is actually equal to that value.


First, such code is impossible in minimal SSA. It should actually be impossible
with the SSAUpdater too, since it generates minimal SSA.

So i'm not sure what would generate it in the first place.
I can't find a non-handmade testcase either.

My suggestion would be to either make it a statistic, or remove it.

Second, this is the ultra slow way of doing it. If it does minimize all cases,
it does so non optimally (IE it is performed more than it needs to be). It's a
bit hard to analyze to determine if it actually minimizes all cases.

The algorithm to minimize these phis is precisely the phi minimization
algorithm added to the new ssaupdater, which is an SCC algorithm that will
minimize all phis in as short a time as possible.

(it depends on the cycle depth. In the case given as an example above, it will
be one pass).

You can run this exactly once on the CFG, at the beginning or end of
instcombine, and feel confident it is minimal ssa again.

-- 
You are receiving this mail because:
You are on the CC list for the bug.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/llvm-bugs/attachments/20170204/d8abcd07/attachment.html>


More information about the llvm-bugs mailing list