[llvm-commits] [llvm] r70557 - in /llvm/trunk: include/llvm/Analysis/ScalarEvolutionExpander.h lib/Analysis/ScalarEvolutionExpander.cpp
Dan Gohman
gohman at apple.com
Fri May 1 10:13:32 PDT 2009
Author: djg
Date: Fri May 1 12:13:31 2009
New Revision: 70557
URL: http://llvm.org/viewvc/llvm-project?rev=70557&view=rev
Log:
Actually insert inserted instructions into the InsertedValues map.
Modified:
llvm/trunk/include/llvm/Analysis/ScalarEvolutionExpander.h
llvm/trunk/lib/Analysis/ScalarEvolutionExpander.cpp
Modified: llvm/trunk/include/llvm/Analysis/ScalarEvolutionExpander.h
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/Analysis/ScalarEvolutionExpander.h?rev=70557&r1=70556&r2=70557&view=diff
==============================================================================
--- llvm/trunk/include/llvm/Analysis/ScalarEvolutionExpander.h (original)
+++ llvm/trunk/include/llvm/Analysis/ScalarEvolutionExpander.h Fri May 1 12:13:31 2009
@@ -106,8 +106,8 @@
/// InsertBinop - Insert the specified binary operator, doing a small amount
/// of work to avoid inserting an obviously redundant operation.
- static Value *InsertBinop(Instruction::BinaryOps Opcode, Value *LHS,
- Value *RHS, BasicBlock::iterator InsertPt);
+ Value *InsertBinop(Instruction::BinaryOps Opcode, Value *LHS,
+ Value *RHS, BasicBlock::iterator InsertPt);
private:
Value *expand(const SCEV *S);
Modified: llvm/trunk/lib/Analysis/ScalarEvolutionExpander.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Analysis/ScalarEvolutionExpander.cpp?rev=70557&r1=70556&r2=70557&view=diff
==============================================================================
--- llvm/trunk/lib/Analysis/ScalarEvolutionExpander.cpp (original)
+++ llvm/trunk/lib/Analysis/ScalarEvolutionExpander.cpp Fri May 1 12:13:31 2009
@@ -64,8 +64,10 @@
return CI;
}
}
- return CastInst::Create(opcode, V, Ty, V->getName(),
- A->getParent()->getEntryBlock().begin());
+ Instruction *I = CastInst::Create(opcode, V, Ty, V->getName(),
+ A->getParent()->getEntryBlock().begin());
+ InsertedValues.insert(I);
+ return I;
}
Instruction *I = cast<Instruction>(V);
@@ -93,7 +95,9 @@
if (InvokeInst *II = dyn_cast<InvokeInst>(I))
IP = II->getNormalDest()->begin();
while (isa<PHINode>(IP)) ++IP;
- return CastInst::Create(opcode, V, Ty, V->getName(), IP);
+ Instruction *CI = CastInst::Create(opcode, V, Ty, V->getName(), IP);
+ InsertedValues.insert(CI);
+ return CI;
}
/// InsertNoopCastOfTo - Insert a cast of V to the specified type,
@@ -135,7 +139,9 @@
}
// If we haven't found this binop, insert it.
- return BinaryOperator::Create(Opcode, LHS, RHS, "tmp", InsertPt);
+ Instruction *BO = BinaryOperator::Create(Opcode, LHS, RHS, "tmp", InsertPt);
+ InsertedValues.insert(BO);
+ return BO;
}
Value *SCEVExpander::visitAddExpr(const SCEVAddExpr *S) {
@@ -218,6 +224,7 @@
// specified loop.
BasicBlock *Header = L->getHeader();
PHINode *PN = PHINode::Create(Ty, "indvar", Header->begin());
+ InsertedValues.insert(PN);
PN->addIncoming(Constant::getNullValue(Ty), L->getLoopPreheader());
pred_iterator HPI = pred_begin(Header);
@@ -231,6 +238,7 @@
Constant *One = ConstantInt::get(Ty, 1);
Instruction *Add = BinaryOperator::CreateAdd(PN, One, "indvar.next",
(*HPI)->getTerminator());
+ InsertedValues.insert(Add);
pred_iterator PI = pred_begin(Header);
if (*PI == L->getLoopPreheader())
@@ -296,21 +304,27 @@
const Type *Ty = SE.getEffectiveSCEVType(S->getType());
Value *V = expand(S->getOperand());
V = InsertNoopCastOfTo(V, SE.getEffectiveSCEVType(V->getType()));
- return new TruncInst(V, Ty, "tmp.", InsertPt);
+ Instruction *I = new TruncInst(V, Ty, "tmp.", InsertPt);
+ InsertedValues.insert(I);
+ return I;
}
Value *SCEVExpander::visitZeroExtendExpr(const SCEVZeroExtendExpr *S) {
const Type *Ty = SE.getEffectiveSCEVType(S->getType());
Value *V = expand(S->getOperand());
V = InsertNoopCastOfTo(V, SE.getEffectiveSCEVType(V->getType()));
- return new ZExtInst(V, Ty, "tmp.", InsertPt);
+ Instruction *I = new ZExtInst(V, Ty, "tmp.", InsertPt);
+ InsertedValues.insert(I);
+ return I;
}
Value *SCEVExpander::visitSignExtendExpr(const SCEVSignExtendExpr *S) {
const Type *Ty = SE.getEffectiveSCEVType(S->getType());
Value *V = expand(S->getOperand());
V = InsertNoopCastOfTo(V, SE.getEffectiveSCEVType(V->getType()));
- return new SExtInst(V, Ty, "tmp.", InsertPt);
+ Instruction *I = new SExtInst(V, Ty, "tmp.", InsertPt);
+ InsertedValues.insert(I);
+ return I;
}
Value *SCEVExpander::visitSMaxExpr(const SCEVSMaxExpr *S) {
@@ -320,8 +334,12 @@
for (unsigned i = 1; i < S->getNumOperands(); ++i) {
Value *RHS = expand(S->getOperand(i));
RHS = InsertNoopCastOfTo(RHS, Ty);
- Value *ICmp = new ICmpInst(ICmpInst::ICMP_SGT, LHS, RHS, "tmp", InsertPt);
- LHS = SelectInst::Create(ICmp, LHS, RHS, "smax", InsertPt);
+ Instruction *ICmp =
+ new ICmpInst(ICmpInst::ICMP_SGT, LHS, RHS, "tmp", InsertPt);
+ InsertedValues.insert(ICmp);
+ Instruction *Sel = SelectInst::Create(ICmp, LHS, RHS, "smax", InsertPt);
+ InsertedValues.insert(Sel);
+ LHS = Sel;
}
return LHS;
}
@@ -333,8 +351,12 @@
for (unsigned i = 1; i < S->getNumOperands(); ++i) {
Value *RHS = expand(S->getOperand(i));
RHS = InsertNoopCastOfTo(RHS, Ty);
- Value *ICmp = new ICmpInst(ICmpInst::ICMP_UGT, LHS, RHS, "tmp", InsertPt);
- LHS = SelectInst::Create(ICmp, LHS, RHS, "umax", InsertPt);
+ Instruction *ICmp =
+ new ICmpInst(ICmpInst::ICMP_UGT, LHS, RHS, "tmp", InsertPt);
+ InsertedValues.insert(ICmp);
+ Instruction *Sel = SelectInst::Create(ICmp, LHS, RHS, "umax", InsertPt);
+ InsertedValues.insert(Sel);
+ LHS = Sel;
}
return LHS;
}
More information about the llvm-commits
mailing list