[llvm] [IVDescriptors] Implement MonotonicDescriptor (PR #214490)
Luke Lau via llvm-commits
llvm-commits at lists.llvm.org
Fri Aug 28 03:20:48 PDT 2026
================
@@ -482,6 +483,67 @@ class InductionDescriptor {
SmallVector<const SCEVPredicate *, 2> NoWrapPredicates;
};
+/// A struct for saving information about monotonic variables.
+/// Monotonic variable can be considered as a "conditional" induction variable:
+/// its update happens only on loop iterations for which a certain predicate is
+/// satisfied. The step of the monotonic variable must be loop-invariant.
+class MonotonicDescriptor {
+public:
+ MonotonicDescriptor() = default;
+
+ MonotonicDescriptor(PHINode *HeaderPHI, PHINode *BackedgePHI,
+ Instruction *StepInst, const SCEV *StartSCEV,
+ const SCEV *StepSCEV, unsigned SCEVNoWrapFlags)
+ : HeaderPHI(HeaderPHI), BackedgePHI(BackedgePHI), StepInst(StepInst),
+ StartSCEV(StartSCEV), StepSCEV(StepSCEV),
+ SCEVNoWrapFlags(SCEVNoWrapFlags) {}
+
+ /// Returns true if \p PN is a monotonic variable in the loop \p L. If \p PN
+ /// is monotonic, the monotonic descriptor \p D will contain the data
+ /// describing the PHI.
+ static bool isMonotonicPHI(PHINode *PN, const Loop *L,
----------------
lukel97 wrote:
I think this needs
```suggestion
LLVM_ABI static bool isMonotonicPHI(PHINode *PN, const Loop *L,
```
https://github.com/llvm/llvm-project/pull/214490
More information about the llvm-commits
mailing list