diff options
author | Dan Gohman <gohman@apple.com> | 2010-02-12 19:20:37 +0000 |
---|---|---|
committer | Dan Gohman <gohman@apple.com> | 2010-02-12 19:20:37 +0000 |
commit | 363f847ec67cfa52912370d6b5c1cc74d5f9b1fe (patch) | |
tree | f9421f89916c18e0dc6293ed027f235e29d6d4ac /llvm/lib/Transforms/Scalar/LoopStrengthReduce.cpp | |
parent | cf20cbec49da37b63310d30cc568bf76ddf29786 (diff) | |
download | bcm5719-llvm-363f847ec67cfa52912370d6b5c1cc74d5f9b1fe.tar.gz bcm5719-llvm-363f847ec67cfa52912370d6b5c1cc74d5f9b1fe.zip |
Fix this code to avoid dereferencing an end() iterator in
offset distributions it doesn't expect.
llvm-svn: 96002
Diffstat (limited to 'llvm/lib/Transforms/Scalar/LoopStrengthReduce.cpp')
-rw-r--r-- | llvm/lib/Transforms/Scalar/LoopStrengthReduce.cpp | 6 |
1 files changed, 5 insertions, 1 deletions
diff --git a/llvm/lib/Transforms/Scalar/LoopStrengthReduce.cpp b/llvm/lib/Transforms/Scalar/LoopStrengthReduce.cpp index 73d3f9db896..a218af94c7e 100644 --- a/llvm/lib/Transforms/Scalar/LoopStrengthReduce.cpp +++ b/llvm/lib/Transforms/Scalar/LoopStrengthReduce.cpp @@ -2271,6 +2271,10 @@ void LSRInstance::GenerateCrossUseConstantOffsets() { 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 @@ void LSRInstance::GenerateCrossUseConstantOffsets() { }; 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; |