[llvm-commits] CVS: llvm/lib/Analysis/ScalarEvolutionExpander.cpp
Chris Lattner
sabre at nondot.org
Tue Apr 17 16:44:08 PDT 2007
Changes in directory llvm/lib/Analysis:
ScalarEvolutionExpander.cpp updated: 1.16 -> 1.17
---
Log message:
Be more careful when inserting reused instructions. This fixes CodeGen/Generic/2007-04-17-lsr-crash.ll
---
Diffs of the changes: (+7 -2)
ScalarEvolutionExpander.cpp | 9 +++++++--
1 files changed, 7 insertions(+), 2 deletions(-)
Index: llvm/lib/Analysis/ScalarEvolutionExpander.cpp
diff -u llvm/lib/Analysis/ScalarEvolutionExpander.cpp:1.16 llvm/lib/Analysis/ScalarEvolutionExpander.cpp:1.17
--- llvm/lib/Analysis/ScalarEvolutionExpander.cpp:1.16 Fri Apr 13 00:04:18 2007
+++ llvm/lib/Analysis/ScalarEvolutionExpander.cpp Tue Apr 17 18:43:50 2007
@@ -71,15 +71,20 @@
/// InsertBinop - Insert the specified binary operator, doing a small amount
/// of work to avoid inserting an obviously redundant operation.
Value *SCEVExpander::InsertBinop(Instruction::BinaryOps Opcode, Value *LHS,
- Value *RHS, Instruction *InsertPt) {
+ Value *RHS, Instruction *&InsertPt) {
// Do a quick scan to see if we have this binop nearby. If so, reuse it.
unsigned ScanLimit = 6;
for (BasicBlock::iterator IP = InsertPt, E = InsertPt->getParent()->begin();
ScanLimit; --IP, --ScanLimit) {
if (BinaryOperator *BinOp = dyn_cast<BinaryOperator>(IP))
if (BinOp->getOpcode() == Opcode && BinOp->getOperand(0) == LHS &&
- BinOp->getOperand(1) == RHS)
+ BinOp->getOperand(1) == RHS) {
+ // If we found the instruction *at* the insert point, insert later
+ // instructions after it.
+ if (BinOp == InsertPt)
+ InsertPt = ++IP;
return BinOp;
+ }
if (IP == E) break;
}
More information about the llvm-commits
mailing list