summaryrefslogtreecommitdiffstats
path: root/llvm/lib/Transforms
diff options
context:
space:
mode:
authorAndrew Trick <atrick@apple.com>2014-10-25 19:42:07 +0000
committerAndrew Trick <atrick@apple.com>2014-10-25 19:42:07 +0000
commit9ccbed5a12fd85eae9ca5571636d21ee34ab4d22 (patch)
tree1abace3e6e9f5b1bc0e673018a759ff4a3889a94 /llvm/lib/Transforms
parent8cdf0425a0c6c836868d0f0e6fef96894131128c (diff)
downloadbcm5719-llvm-9ccbed5a12fd85eae9ca5571636d21ee34ab4d22.tar.gz
bcm5719-llvm-9ccbed5a12fd85eae9ca5571636d21ee34ab4d22.zip
Fix LSR compile time.
This is a simple fix that brings the compilation time from 5min to 5s on a specific real-world example. It's a large chain of computation in a crypto routine (always a problem for SCEV). A unit test is not feasible and there would be no way to check it. The fix is just basic good practice for dealing with SCEVs, there's no risk of regression. Patch by Daniel Reynaud! llvm-svn: 220622
Diffstat (limited to 'llvm/lib/Transforms')
-rw-r--r--llvm/lib/Transforms/Scalar/LoopStrengthReduce.cpp5
1 files changed, 5 insertions, 0 deletions
diff --git a/llvm/lib/Transforms/Scalar/LoopStrengthReduce.cpp b/llvm/lib/Transforms/Scalar/LoopStrengthReduce.cpp
index fbc8e0e1e7b..e1d18e8f99b 100644
--- a/llvm/lib/Transforms/Scalar/LoopStrengthReduce.cpp
+++ b/llvm/lib/Transforms/Scalar/LoopStrengthReduce.cpp
@@ -3117,10 +3117,15 @@ void
LSRInstance::CollectLoopInvariantFixupsAndFormulae() {
SmallVector<const SCEV *, 8> Worklist(RegUses.begin(), RegUses.end());
SmallPtrSet<const SCEV *, 8> Inserted;
+ SmallPtrSet<const SCEV *, 32> Done;
while (!Worklist.empty()) {
const SCEV *S = Worklist.pop_back_val();
+ // Don't process the same SCEV twice
+ if (!Done.insert(S))
+ continue;
+
if (const SCEVNAryExpr *N = dyn_cast<SCEVNAryExpr>(S))
Worklist.append(N->op_begin(), N->op_end());
else if (const SCEVCastExpr *C = dyn_cast<SCEVCastExpr>(S))
OpenPOWER on IntegriCloud