diff options
author | Chris Lattner <sabre@nondot.org> | 2007-04-17 23:43:50 +0000 |
---|---|---|
committer | Chris Lattner <sabre@nondot.org> | 2007-04-17 23:43:50 +0000 |
commit | b1b2f0bc44d01b33198a3aa51a64f79bad01378f (patch) | |
tree | 55fb039b15ccd881aad8cec956bd3b12a9294480 /lib | |
parent | a00a5b95e74cd14d96d6f15e7363d7323fb94180 (diff) | |
download | external_llvm-b1b2f0bc44d01b33198a3aa51a64f79bad01378f.zip external_llvm-b1b2f0bc44d01b33198a3aa51a64f79bad01378f.tar.gz external_llvm-b1b2f0bc44d01b33198a3aa51a64f79bad01378f.tar.bz2 |
Be more careful when inserting reused instructions. This fixes CodeGen/Generic/2007-04-17-lsr-crash.ll
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@36231 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib')
-rw-r--r-- | lib/Analysis/ScalarEvolutionExpander.cpp | 9 |
1 files changed, 7 insertions, 2 deletions
diff --git a/lib/Analysis/ScalarEvolutionExpander.cpp b/lib/Analysis/ScalarEvolutionExpander.cpp index a9b88c1..c88c781 100644 --- a/lib/Analysis/ScalarEvolutionExpander.cpp +++ b/lib/Analysis/ScalarEvolutionExpander.cpp @@ -71,15 +71,20 @@ Value *SCEVExpander::InsertCastOfTo(Instruction::CastOps opcode, Value *V, /// 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; } |