[llvm] [ValueTracking] Add `matchSimpleBinaryIntrinsicRecurrence` helper (PR #145964)
Nikita Popov via llvm-commits
llvm-commits at lists.llvm.org
Fri Jun 27 08:36:12 PDT 2025
================
@@ -965,6 +966,21 @@ LLVM_ABI bool matchSimpleRecurrence(const PHINode *P, BinaryOperator *&BO,
LLVM_ABI bool matchSimpleRecurrence(const BinaryOperator *I, PHINode *&P,
Value *&Start, Value *&Step);
+/// Attempt to match a simple value-accumulating recurrence of the form:
+/// %llvm.intrinsic.acc = phi Ty [%Init, %Entry], [%llvm.intrinsic, %backedge]
+/// %llvm.intrinsic = call Ty @llvm.intrinsic(%OtherOp, %llvm.intrinsic.acc)
+/// OR
+/// %llvm.intrinsic.acc = phi Ty [%Init, %Entry], [%llvm.intrinsic, %backedge]
+/// %llvm.intrinsic = call Ty @llvm.intrinsic(%llvm.intrinsic.acc, %OtherOp)
+///
+/// The recurrence relation is of kind:
+/// X_0 = %a (initial value),
+/// X_i = call @llvm.binary.intrinsic(X_i-1, %b)
+/// Where %b may be a loop-invariant value.
----------------
nikic wrote:
I still find the phrasing here confusing...
```suggestion
/// Where %b is not required to be loop-invariant.
```
https://github.com/llvm/llvm-project/pull/145964
More information about the llvm-commits
mailing list