[llvm] [InstCombine] fold (A + B - C == B) -> (A == C). (PR #76129)
Yingwei Zheng via llvm-commits
llvm-commits at lists.llvm.org
Thu Dec 28 23:59:56 PST 2023
================
@@ -4547,6 +4547,48 @@ static Instruction *foldICmpXorXX(ICmpInst &I, const SimplifyQuery &Q,
return nullptr;
}
+// extract common factors like ((A + B) - C == B) -> (A - C == 0)
+Instruction *InstCombinerImpl::foldICmpWithCommonFactors(ICmpInst &Cmp,
+ BinaryOperator *LBO,
+ Value *RHS) {
+ const CmpInst::Predicate Pred = Cmp.getPredicate();
+ if (!ICmpInst::isEquality(Pred))
+ return nullptr;
+
+ if (LBO->getOpcode() != Instruction::Add &&
+ LBO->getOpcode() != Instruction::Sub)
+ return nullptr;
+
+ SmallVector<BinaryOperator *, 16> worklist;
----------------
dtcxzyw wrote:
What is the compile-time impact of the worklist based algorithm? Should we set a maximum size of the add-sub chain?
https://github.com/llvm/llvm-project/pull/76129
More information about the llvm-commits
mailing list