mirror of
https://github.com/c64scene-ar/llvm-6502.git
synced 2025-08-03 15:26:18 +00:00
Fold select + select where both selects are on the same condition.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@124469 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
@@ -792,6 +792,19 @@ Instruction *InstCombiner::visitSelectInst(SelectInst &SI) {
|
||||
if (Instruction *NV = FoldOpIntoPhi(SI))
|
||||
return NV;
|
||||
|
||||
if (SelectInst *TrueSI = dyn_cast<SelectInst>(TrueVal)) {
|
||||
if (TrueSI->getCondition() == CondVal) {
|
||||
SI.setOperand(1, TrueSI->getTrueValue());
|
||||
return &SI;
|
||||
}
|
||||
}
|
||||
if (SelectInst *FalseSI = dyn_cast<SelectInst>(FalseVal)) {
|
||||
if (FalseSI->getCondition() == CondVal) {
|
||||
SI.setOperand(2, FalseSI->getFalseValue());
|
||||
return &SI;
|
||||
}
|
||||
}
|
||||
|
||||
if (BinaryOperator::isNot(CondVal)) {
|
||||
SI.setOperand(0, BinaryOperator::getNotArgument(CondVal));
|
||||
SI.setOperand(1, FalseVal);
|
||||
|
Reference in New Issue
Block a user