diff options
author | Chris Lattner <sabre@nondot.org> | 2002-09-10 17:04:02 +0000 |
---|---|---|
committer | Chris Lattner <sabre@nondot.org> | 2002-09-10 17:04:02 +0000 |
commit | 2a7c23ef9156a97f426a3fe8d1f5935b75d076d1 (patch) | |
tree | 55142cb1a54f1dfc3c68c196b1070bb94e73b51a /lib/Transforms/Scalar/Reassociate.cpp | |
parent | 3ea5cb0df1a992b900b6eefb9da2505792c2c819 (diff) |
Simplify code (somtimes dramatically), by using the new "auto-insert" feature
of instruction constructors.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@3656 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/Transforms/Scalar/Reassociate.cpp')
-rw-r--r-- | lib/Transforms/Scalar/Reassociate.cpp | 18 |
1 files changed, 8 insertions, 10 deletions
diff --git a/lib/Transforms/Scalar/Reassociate.cpp b/lib/Transforms/Scalar/Reassociate.cpp index 24d7dcebe8..7d76bfb681 100644 --- a/lib/Transforms/Scalar/Reassociate.cpp +++ b/lib/Transforms/Scalar/Reassociate.cpp @@ -180,12 +180,9 @@ static Value *NegateValue(Value *V, BasicBlock *BB, BasicBlock::iterator &BI) { // adding it now, we are assured that the neg instructions we just // inserted dominate the instruction we are about to insert after them. // - BasicBlock::iterator NBI = cast<Instruction>(RHS); - - Instruction *Add = - BinaryOperator::create(Instruction::Add, LHS, RHS, I->getName()+".neg"); - BB->getInstList().insert(++NBI, Add); // Add to the basic block... - return Add; + return BinaryOperator::create(Instruction::Add, LHS, RHS, + I->getName()+".neg", + cast<Instruction>(RHS)->getNext()); } // Insert a 'neg' instruction that subtracts the value from zero to get the @@ -194,8 +191,8 @@ static Value *NegateValue(Value *V, BasicBlock *BB, BasicBlock::iterator &BI) { Instruction *Neg = BinaryOperator::create(Instruction::Sub, Constant::getNullValue(V->getType()), V, - V->getName()+".neg"); - BI = BB->getInstList().insert(BI, Neg); // Add to the basic block... + V->getName()+".neg", BI); + --BI; return Neg; } @@ -220,8 +217,9 @@ bool Reassociate::ReassociateBB(BasicBlock *BB) { // Insert a new temporary instruction... (A+B)+C BinaryOperator *Tmp = BinaryOperator::create(I->getOpcode(), LHSI, RHSI->getOperand(0), - RHSI->getName()+".ra"); - BI = BB->getInstList().insert(BI, Tmp); // Add to the basic block... + RHSI->getName()+".ra", + BI); + BI = Tmp; I->setOperand(0, Tmp); I->setOperand(1, RHSI->getOperand(1)); |