[llvm] [InstCombine] Match intrinsic recurrences when known to be hoisted (PR #149858)
Nikita Popov via llvm-commits
llvm-commits at lists.llvm.org
Tue Jul 22 07:01:31 PDT 2025
================
@@ -1532,6 +1532,46 @@ static Instruction *foldBitOrderCrossLogicOp(Value *V,
return nullptr;
}
+static bool foldBinaryIntrinsicRecurrence(InstCombinerImpl &IC,
+ IntrinsicInst *II) {
+ PHINode *PN;
+ Value *Init, *OtherOp;
+
+ // A binary intrinsic recurrence with loop-invariant operands is equivalent to
+ // `call @llvm.binary.intrinsic(Init, OtherOp)`.
+ if (!matchSimpleBinaryIntrinsicRecurrence(II, PN, Init, OtherOp) ||
+ isa<Constant>(OtherOp) || !PN->hasOneUse() ||
+ !IC.getDominatorTree().dominates(OtherOp, PN))
----------------
nikic wrote:
I'd prefer using PN->getParent() here, though I think it will behave the same.
https://github.com/llvm/llvm-project/pull/149858
More information about the llvm-commits
mailing list