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