[llvm] [InstCombine] Introduce `foldICmpBinOpWithConstantViaTruthTable` folding (PR #139109)
Nikita Popov via llvm-commits
llvm-commits at lists.llvm.org
Mon May 12 00:40:02 PDT 2025
================
@@ -3110,6 +3086,45 @@ static Value *createLogicFromTable(const std::bitset<4> &Table, Value *Op0,
return nullptr;
}
+Instruction *InstCombinerImpl::foldICmpBinOpWithConstantViaTruthTable(
+ ICmpInst &Cmp, BinaryOperator *BO, const APInt &C) {
+ Value *A, *B;
+ Constant *C1, *C2, *C3, *C4;
+ if (match(BO->getOperand(0),
+ m_Select(m_Value(A), m_Constant(C1), m_Constant(C2))) &&
+ match(BO->getOperand(1),
+ m_Select(m_Value(B), m_Constant(C3), m_Constant(C4))) &&
+ Cmp.getType() == A->getType()) {
----------------
nikic wrote:
Early return?
https://github.com/llvm/llvm-project/pull/139109
More information about the llvm-commits
mailing list