diff --git a/llvm/lib/Transforms/InstCombine/InstCombineSelect.cpp b/llvm/lib/Transforms/InstCombine/InstCombineSelect.cpp index 9360adc2d3add0..9870abb3b6cb28 100644 --- a/llvm/lib/Transforms/InstCombine/InstCombineSelect.cpp +++ b/llvm/lib/Transforms/InstCombine/InstCombineSelect.cpp @@ -1123,7 +1123,7 @@ Instruction *InstCombinerImpl::foldSelectValueEquivalence(SelectInst &Sel, // else. Only do this if CmpRHS is a constant, as profitability is not // clear for other cases. // FIXME: The replacement could be performed recursively. - if (isa(CmpRHS) && !isa(CmpRHS)) + if (match(CmpRHS, m_ImmConstant()) && !match(CmpLHS, m_ImmConstant())) if (auto *I = dyn_cast(TrueVal)) if (I->hasOneUse()) for (Use &U : I->operands())