aboutsummaryrefslogtreecommitdiff
path: root/llvm/lib/Transforms/Utils/LoopUnroll.cpp
diff options
context:
space:
mode:
authorChandler Carruth <chandlerc@gmail.com>2017-01-21 04:16:53 +0000
committerChandler Carruth <chandlerc@gmail.com>2017-01-21 04:16:53 +0000
commit7fd29cef421c0dc0c52279ebd3f0fbbb2e534c35 (patch)
tree35d35d46c7a071946c7f592eecc724edb788b4c3 /llvm/lib/Transforms/Utils/LoopUnroll.cpp
parent17350de1cab38961ae3636f01b2bcad4c6d0d278 (diff)
downloadllvm-7fd29cef421c0dc0c52279ebd3f0fbbb2e534c35.zip
llvm-7fd29cef421c0dc0c52279ebd3f0fbbb2e534c35.tar.gz
llvm-7fd29cef421c0dc0c52279ebd3f0fbbb2e534c35.tar.bz2
[PM] Sink an LCSSA preservation assert from the LoopSimplify pass into
the library routine shared with the new PM and other code. This assert checks that when LCSSA preservation is requested we start in LCSSA form. Without this early assert, given *very* complex test cases we can hit an assert or crash much later on when trying to preserve LCSSA. The new PM's loop simplify doesn't need to (and indeed can't) preserve LCSSA as the new PM doesn't deal in transforms in the dependency graph. But we asked the library to and shockingly, this didn't work very well! Stop doing that. Now the assert will tell us immediately with existing test cases. Before this, it took a pretty convoluted input to trigger this. However, sinking the assert also found a bug in LoopUnroll where we asked simplifyLoop to preserve LCSSA *right before we reform it*. That's kinda silly and unsurprising that it wasn't available. =D Stop doing that too. We also would assert that the unrolled loop was in LCSSA even if preserving LCSSA was never requested! I don't have a test case or anything here. I spotted it by inspection and it seems quite obvious. No logic change anyways, that's just avoiding a spurrious assert. llvm-svn: 292710
Diffstat (limited to 'llvm/lib/Transforms/Utils/LoopUnroll.cpp')
-rw-r--r--llvm/lib/Transforms/Utils/LoopUnroll.cpp7
1 files changed, 5 insertions, 2 deletions
diff --git a/llvm/lib/Transforms/Utils/LoopUnroll.cpp b/llvm/lib/Transforms/Utils/LoopUnroll.cpp
index 9ea4a4b..ea86712 100644
--- a/llvm/lib/Transforms/Utils/LoopUnroll.cpp
+++ b/llvm/lib/Transforms/Utils/LoopUnroll.cpp
@@ -750,7 +750,10 @@ bool llvm::UnrollLoop(Loop *L, unsigned Count, unsigned TripCount, bool Force,
// loops too).
// TODO: That potentially might be compile-time expensive. We should try
// to fix the loop-simplified form incrementally.
- simplifyLoop(OuterL, DT, LI, SE, AC, PreserveLCSSA);
+ // Note that we only preserve LCSSA at this stage if we need to and if we
+ // won't end up fixing it. If we end up fixing it anyways, we don't need
+ // to preserve it here and in fact we can't because it isn't correct.
+ simplifyLoop(OuterL, DT, LI, SE, AC, PreserveLCSSA && !NeedToFixLCSSA);
// LCSSA must be performed on the outermost affected loop. The unrolled
// loop's last loop latch is guaranteed to be in the outermost loop after
@@ -762,7 +765,7 @@ bool llvm::UnrollLoop(Loop *L, unsigned Count, unsigned TripCount, bool Force,
if (NeedToFixLCSSA)
formLCSSARecursively(*OuterL, *DT, LI, SE);
- else
+ else if (PreserveLCSSA)
assert(OuterL->isLCSSAForm(*DT) &&
"Loops should be in LCSSA form after loop-unroll.");
} else {