[llvm] [InstCombine] Offset both sides of an equality icmp (PR #134086)
Yingwei Zheng via llvm-commits
llvm-commits at lists.llvm.org
Mon Apr 28 22:59:14 PDT 2025
================
@@ -5808,6 +5808,129 @@ static Instruction *foldICmpPow2Test(ICmpInst &I,
return nullptr;
}
+/// Find all possible pairs (BinOp, RHS) that BinOp V, RHS can be simplified.
+using OffsetOp = std::pair<Instruction::BinaryOps, Value *>;
+static void collectOffsetOp(Value *V, SmallVectorImpl<OffsetOp> &Offsets,
+ bool AllowRecursion) {
+ Instruction *Inst = dyn_cast<Instruction>(V);
+ if (!Inst || !Inst->hasOneUse())
+ return;
+
+ switch (Inst->getOpcode()) {
+ case Instruction::Add:
+ if (isGuaranteedNotToBeUndefOrPoison(Inst->getOperand(1)))
----------------
dtcxzyw wrote:
I will add tests later.
https://github.com/llvm/llvm-project/pull/134086
More information about the llvm-commits
mailing list