diff options
Diffstat (limited to 'llvm/lib/Transforms/Scalar/Reassociate.cpp')
-rw-r--r-- | llvm/lib/Transforms/Scalar/Reassociate.cpp | 36 |
1 files changed, 6 insertions, 30 deletions
diff --git a/llvm/lib/Transforms/Scalar/Reassociate.cpp b/llvm/lib/Transforms/Scalar/Reassociate.cpp index 87546a7..3bd1234 100644 --- a/llvm/lib/Transforms/Scalar/Reassociate.cpp +++ b/llvm/lib/Transforms/Scalar/Reassociate.cpp @@ -886,40 +886,16 @@ static Value *NegateValue(Value *V, Instruction *BI, if (TheNeg->getParent()->getParent() != BI->getParent()->getParent()) continue; - bool FoundCatchSwitch = false; - - BasicBlock::iterator InsertPt; + Instruction *InsertPt; if (Instruction *InstInput = dyn_cast<Instruction>(V)) { - if (InvokeInst *II = dyn_cast<InvokeInst>(InstInput)) { - InsertPt = II->getNormalDest()->begin(); - } else { - InsertPt = ++InstInput->getIterator(); - } - - const BasicBlock *BB = InsertPt->getParent(); - - // Make sure we don't move anything before PHIs or exception - // handling pads. - while (InsertPt != BB->end() && (isa<PHINode>(InsertPt) || - InsertPt->isEHPad())) { - if (isa<CatchSwitchInst>(InsertPt)) - // A catchswitch cannot have anything in the block except - // itself and PHIs. We'll bail out below. - FoundCatchSwitch = true; - ++InsertPt; - } + InsertPt = InstInput->getInsertionPointAfterDef(); + if (!InsertPt) + continue; } else { - InsertPt = TheNeg->getParent()->getParent()->getEntryBlock().begin(); + InsertPt = &*TheNeg->getFunction()->getEntryBlock().begin(); } - // We found a catchswitch in the block where we want to move the - // neg. We cannot move anything into that block. Bail and just - // create the neg before BI, as if we hadn't found an existing - // neg. - if (FoundCatchSwitch) - break; - - TheNeg->moveBefore(&*InsertPt); + TheNeg->moveBefore(InsertPt); if (TheNeg->getOpcode() == Instruction::Sub) { TheNeg->setHasNoUnsignedWrap(false); TheNeg->setHasNoSignedWrap(false); |