summaryrefslogtreecommitdiffstats
path: root/llvm/lib/Transforms/Scalar/LoopFuse.cpp
diff options
context:
space:
mode:
authorRichard Trieu <rtrieu@google.com>2019-04-18 01:39:45 +0000
committerRichard Trieu <rtrieu@google.com>2019-04-18 01:39:45 +0000
commit7b6192025e8f183f0ea84ba9d59da7374727e8a6 (patch)
tree5f809793d390ddee4cdd5839bfe7ac7e4666393d /llvm/lib/Transforms/Scalar/LoopFuse.cpp
parentea6037d84eddd9185b5e3eae5ce0675f4e158b36 (diff)
downloadbcm5719-llvm-7b6192025e8f183f0ea84ba9d59da7374727e8a6.tar.gz
bcm5719-llvm-7b6192025e8f183f0ea84ba9d59da7374727e8a6.zip
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. llvm-svn: 358636
Diffstat (limited to 'llvm/lib/Transforms/Scalar/LoopFuse.cpp')
-rw-r--r--llvm/lib/Transforms/Scalar/LoopFuse.cpp14
1 files changed, 8 insertions, 6 deletions
diff --git a/llvm/lib/Transforms/Scalar/LoopFuse.cpp b/llvm/lib/Transforms/Scalar/LoopFuse.cpp
index a50cb0a1d96..bf45e5a8e75 100644
--- a/llvm/lib/Transforms/Scalar/LoopFuse.cpp
+++ b/llvm/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.
OpenPOWER on IntegriCloud