[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:32 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() ||
----------------
nikic wrote:
Similarly, I don't think excluding multi-use phi is necessary. In that case the phi would stay, but we'd still make the intrinsic loop-invariant. Or do you think that's not profitable?
https://github.com/llvm/llvm-project/pull/149858
More information about the llvm-commits
mailing list