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 | 135a077c93ea6664d24323e9781fb5f4b18a9831 (patch) | |
tree | cf66a341d357a3fc7cd71bc9ee83b4a813d773cc /llvm/lib/Analysis | |
parent | 4fe9eb50527beae1b6f667cda0a1e2dc366a6d75 (diff) | |
download | bcm5719-llvm-135a077c93ea6664d24323e9781fb5f4b18a9831.tar.gz bcm5719-llvm-135a077c93ea6664d24323e9781fb5f4b18a9831.zip |
Be more careful when inserting reused instructions. This fixes CodeGen/Generic/2007-04-17-lsr-crash.ll
llvm-svn: 36231
Diffstat (limited to 'llvm/lib/Analysis')
-rw-r--r-- | llvm/lib/Analysis/ScalarEvolutionExpander.cpp | 9 |
1 files changed, 7 insertions, 2 deletions
diff --git a/llvm/lib/Analysis/ScalarEvolutionExpander.cpp b/llvm/lib/Analysis/ScalarEvolutionExpander.cpp index a9b88c1155e..c88c7811954 100644 --- a/llvm/lib/Analysis/ScalarEvolutionExpander.cpp +++ b/llvm/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; } |