Make use of BinaryOperator::create* methods to shrinkify code.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@14262 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
Chris Lattner 2004-06-20 05:04:01 +00:00
parent 762a76b891
commit c5c5e6afe5

View File

@ -175,8 +175,7 @@ namespace {
// Emit a bunch of add instructions
for (int i = S->getNumOperands()-2; i >= 0; --i)
V = BinaryOperator::create(Instruction::Add, V,
expandInTy(S->getOperand(i), Ty),
V = BinaryOperator::createAdd(V, expandInTy(S->getOperand(i), Ty),
"tmp.", InsertPt);
return V;
}
@ -187,8 +186,7 @@ namespace {
const Type *Ty = S->getType();
Value *LHS = expandInTy(S->getLHS(), Ty);
Value *RHS = expandInTy(S->getRHS(), Ty);
return BinaryOperator::create(Instruction::Div, LHS, RHS, "tmp.",
InsertPt);
return BinaryOperator::createDiv(LHS, RHS, "tmp.", InsertPt);
}
Value *visitAddRecExpr(SCEVAddRecExpr *S);
@ -211,13 +209,11 @@ Value *SCEVExpander::visitMulExpr(SCEVMulExpr *S) {
// Emit a bunch of multiply instructions
for (; i >= FirstOp; --i)
V = BinaryOperator::create(Instruction::Mul, V,
expandInTy(S->getOperand(i), Ty),
V = BinaryOperator::createMul(V, expandInTy(S->getOperand(i), Ty),
"tmp.", InsertPt);
// -1 * ... ---> 0 - ...
if (FirstOp == 1)
V = BinaryOperator::create(Instruction::Sub, Constant::getNullValue(Ty),
V, "tmp.", InsertPt);
V = BinaryOperator::createNeg(V, "tmp.", InsertPt);
return V;
}
@ -236,8 +232,7 @@ Value *SCEVExpander::visitAddRecExpr(SCEVAddRecExpr *S) {
Value *Rest = expandInTy(SCEVAddRecExpr::get(NewOps, L), Ty);
// FIXME: look for an existing add to use.
return BinaryOperator::create(Instruction::Add, Rest, Start, "tmp.",
InsertPt);
return BinaryOperator::createAdd(Rest, Start, "tmp.", InsertPt);
}
// {0,+,1} --> Insert a canonical induction variable into the loop!
@ -259,8 +254,7 @@ Value *SCEVExpander::visitAddRecExpr(SCEVAddRecExpr *S) {
// to the back-edge.
Constant *One = Ty->isFloatingPoint() ? (Constant*)ConstantFP::get(Ty, 1.0)
: ConstantInt::get(Ty, 1);
Instruction *Add = BinaryOperator::create(Instruction::Add, PN, One,
"indvar.next",
Instruction *Add = BinaryOperator::createAdd(PN, One, "indvar.next",
(*HPI)->getTerminator());
pred_iterator PI = pred_begin(Header);
@ -275,7 +269,7 @@ Value *SCEVExpander::visitAddRecExpr(SCEVAddRecExpr *S) {
if (S->getNumOperands() == 2) { // {0,+,F} --> i*F
Value *F = expandInTy(S->getOperand(1), Ty);
return BinaryOperator::create(Instruction::Mul, I, F, "tmp.", InsertPt);
return BinaryOperator::createMul(I, F, "tmp.", InsertPt);
}
// If this is a chain of recurrences, turn it into a closed form, using the
@ -380,11 +374,10 @@ void IndVarSimplify::EliminatePointerRecurrence(PHINode *PN,
// Insert a new integer PHI node into the top of the block.
PHINode *NewPhi = new PHINode(AddedVal->getType(),
PN->getName()+".rec", PN);
NewPhi->addIncoming(Constant::getNullValue(NewPhi->getType()),
Preheader);
NewPhi->addIncoming(Constant::getNullValue(NewPhi->getType()), Preheader);
// Create the new add instruction.
Value *NewAdd = BinaryOperator::create(Instruction::Add, NewPhi,
AddedVal,
Value *NewAdd = BinaryOperator::createAdd(NewPhi, AddedVal,
GEPI->getName()+".rec", GEPI);
NewPhi->addIncoming(NewAdd, PN->getIncomingBlock(BackedgeIdx));