[llvm] [InstCombine] Fold operation into select, when one operand is zext of select's condition (PR #166816)
Gábor Spaits via llvm-commits
llvm-commits at lists.llvm.org
Fri Nov 7 00:14:21 PST 2025
================
@@ -1758,6 +1758,9 @@ static Value *simplifyOperationIntoSelectOperand(Instruction &I, SelectInst *SI,
m_Specific(Op), m_Value(V))) &&
isGuaranteedNotToBeUndefOrPoison(V)) {
// Pass
+ } else if (match(Op, m_ZExt(m_Specific(SI->getCondition())))) {
+ V = IsTrueArm ? ConstantInt::get(Op->getType(), 1)
+ : ConstantInt::getNullValue(Op->getType());
----------------
spaits wrote:
Shouldn't we add the same for `sext` instruction? I know that we don't have any evidence of any frontend that would generate that pattern, but it may happen and the handling wouldn't mean a significant cost burden.
https://github.com/llvm/llvm-project/pull/166816
More information about the llvm-commits
mailing list