From: Richard Trieu Date: Thu, 18 Apr 2019 01:39:45 +0000 (+0000) Subject: Fix bad compare function over FusionCandidate. X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=8738b3dc1b15e4b26a98c01db6dd0dd8aa570335;p=llvm Fix bad compare function over FusionCandidate. Reverse the checking of the domiance order so that when a self compare happens, it returns false. This makes compare function have strict weak ordering. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@358636 91177308-0d34-0410-b5e6-96231b3b80d8 --- diff --git a/lib/Transforms/Scalar/LoopFuse.cpp b/lib/Transforms/Scalar/LoopFuse.cpp index a50cb0a1d96..bf45e5a8e75 100644 --- a/lib/Transforms/Scalar/LoopFuse.cpp +++ b/lib/Transforms/Scalar/LoopFuse.cpp @@ -264,18 +264,20 @@ struct FusionCandidateCompare { // will trigger an unused variable warning if building without asserts. assert(DT && LHS.PDT && "Expecting valid dominator tree"); - if (DT->dominates(LHS.Preheader, RHS.Preheader)) { - // Verify RHS Postdominates LHS - assert(LHS.PDT->dominates(RHS.Preheader, LHS.Preheader)); - return true; - } - + // Do this compare first so if LHS == RHS, function returns false. if (DT->dominates(RHS.Preheader, LHS.Preheader)) { // RHS dominates LHS // Verify LHS post-dominates RHS assert(LHS.PDT->dominates(LHS.Preheader, RHS.Preheader)); return false; } + + if (DT->dominates(LHS.Preheader, RHS.Preheader)) { + // Verify RHS Postdominates LHS + assert(LHS.PDT->dominates(RHS.Preheader, LHS.Preheader)); + return true; + } + // If LHS does not dominate RHS and RHS does not dominate LHS then there is // no dominance relationship between the two FusionCandidates. Thus, they // should not be in the same set together.