[llvm-commits] [llvm] r96002 - /llvm/trunk/lib/Transforms/Scalar/LoopStrengthReduce.cpp
Dan Gohman
gohman at apple.com
Fri Feb 12 11:20:37 PST 2010
Author: djg
Date: Fri Feb 12 13:20:37 2010
New Revision: 96002
URL: http://llvm.org/viewvc/llvm-project?rev=96002&view=rev
Log:
Fix this code to avoid dereferencing an end() iterator in
offset distributions it doesn't expect.
Modified:
llvm/trunk/lib/Transforms/Scalar/LoopStrengthReduce.cpp
Modified: llvm/trunk/lib/Transforms/Scalar/LoopStrengthReduce.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Transforms/Scalar/LoopStrengthReduce.cpp?rev=96002&r1=96001&r2=96002&view=diff
==============================================================================
--- llvm/trunk/lib/Transforms/Scalar/LoopStrengthReduce.cpp (original)
+++ llvm/trunk/lib/Transforms/Scalar/LoopStrengthReduce.cpp Fri Feb 12 13:20:37 2010
@@ -2271,6 +2271,10 @@
const SCEV *Reg = *I;
const ImmMapTy &Imms = Map.find(Reg)->second;
+ // It's not worthwhile looking for reuse if there's only one offset.
+ if (Imms.size() == 1)
+ continue;
+
DEBUG(dbgs() << "Generating cross-use offsets for " << *Reg << ':';
for (ImmMapTy::const_iterator J = Imms.begin(), JE = Imms.end();
J != JE; ++J)
@@ -2299,7 +2303,7 @@
};
for (size_t i = 0, e = array_lengthof(OtherImms); i != e; ++i) {
ImmMapTy::const_iterator M = OtherImms[i];
- if (M == J) continue;
+ if (M == J || M == JE) continue;
// Compute the difference between the two.
int64_t Imm = (uint64_t)JImm - M->first;
More information about the llvm-commits
mailing list