mirror of
https://github.com/c64scene-ar/llvm-6502.git
synced 2025-07-25 13:24:46 +00:00
Do not insert trivially dead select instructions, which allows us to
potentially fold more in one pass. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@16583 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
@@ -753,10 +753,19 @@ bool llvm::SimplifyCFG(BasicBlock *BB) {
|
|||||||
FalseSucc->removePredecessor(BI->getParent());
|
FalseSucc->removePredecessor(BI->getParent());
|
||||||
|
|
||||||
// Insert a new select instruction.
|
// Insert a new select instruction.
|
||||||
Value *NewRetVal = new SelectInst(BI->getCondition(), TrueValue,
|
Value *NewRetVal;
|
||||||
|
Value *BrCond = BI->getCondition();
|
||||||
|
if (TrueValue != FalseValue)
|
||||||
|
NewRetVal = new SelectInst(BrCond, TrueValue,
|
||||||
FalseValue, "retval", BI);
|
FalseValue, "retval", BI);
|
||||||
|
else
|
||||||
|
NewRetVal = TrueValue;
|
||||||
|
|
||||||
new ReturnInst(NewRetVal, BI);
|
new ReturnInst(NewRetVal, BI);
|
||||||
BI->getParent()->getInstList().erase(BI);
|
BI->getParent()->getInstList().erase(BI);
|
||||||
|
if (BrCond->use_empty())
|
||||||
|
if (Instruction *BrCondI = dyn_cast<Instruction>(BrCond))
|
||||||
|
BrCondI->getParent()->getInstList().erase(BrCondI);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user