Skip to content

Commit

Permalink
[InstCombine] Remove some redundant select folds (NFCI)
Browse files Browse the repository at this point in the history
simplifyWithOpReplaced() has become more powerful in the
meantime, subsuming these folds.
  • Loading branch information
nikic committed Oct 24, 2023
1 parent 2df69ed commit d3cf00b
Showing 1 changed file with 0 additions and 22 deletions.
22 changes: 0 additions & 22 deletions llvm/lib/Transforms/InstCombine/InstCombineSelect.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -3391,28 +3391,6 @@ Instruction *InstCombinerImpl::visitSelectInst(SelectInst &SI) {
ConstantInt::getFalse(CondType), SQ,
/* AllowRefinement */ true))
return replaceOperand(SI, 2, S);

// Handle patterns involving sext/zext + not explicitly,
// as simplifyWithOpReplaced() only looks past one instruction.
Value *NotCond;

// select a, sext(!a), b -> select !a, b, 0
// select a, zext(!a), b -> select !a, b, 0
if (match(TrueVal, m_ZExtOrSExt(m_CombineAnd(m_Value(NotCond),
m_Not(m_Specific(CondVal))))))
return SelectInst::Create(NotCond, FalseVal,
Constant::getNullValue(SelType));

// select a, b, zext(!a) -> select !a, 1, b
if (match(FalseVal, m_ZExt(m_CombineAnd(m_Value(NotCond),
m_Not(m_Specific(CondVal))))))
return SelectInst::Create(NotCond, ConstantInt::get(SelType, 1), TrueVal);

// select a, b, sext(!a) -> select !a, -1, b
if (match(FalseVal, m_SExt(m_CombineAnd(m_Value(NotCond),
m_Not(m_Specific(CondVal))))))
return SelectInst::Create(NotCond, Constant::getAllOnesValue(SelType),
TrueVal);
}

if (Instruction *R = foldSelectOfBools(SI))
Expand Down

0 comments on commit d3cf00b

Please sign in to comment.