[llvm] [LV, VP]VP intrinsics support for the Loop Vectorizer (PR #76172)

Florian Hahn via llvm-commits llvm-commits at lists.llvm.org
Fri Jan 26 08:36:32 PST 2024


================
@@ -2288,6 +2298,39 @@ class VPActiveLaneMaskPHIRecipe : public VPHeaderPHIRecipe {
 #endif
 };
 
+/// A recipe for generating the phi node for the current index of elements,
+/// adjusted in accordance with EVL value. It starts at StartIV value and gets
+/// incremented by EVL in each iteration of the vector loop.
+class VPEVLBasedIVPHIRecipe : public VPHeaderPHIRecipe {
+public:
+  VPEVLBasedIVPHIRecipe(VPValue *StartMask, DebugLoc DL)
+      : VPHeaderPHIRecipe(VPDef::VPEVLBasedIVPHISC, nullptr, StartMask, DL) {}
+
+  ~VPEVLBasedIVPHIRecipe() override = default;
+
+  VP_CLASSOF_IMPL(VPDef::VPEVLBasedIVPHISC)
+
+  static inline bool classof(const VPHeaderPHIRecipe *D) {
+    return D->getVPDefID() == VPDef::VPEVLBasedIVPHISC;
+  }
+
+  /// Generate phi for handling IV based on EVL over iterations correctly.
+  void execute(VPTransformState &State) override;
----------------
fhahn wrote:

> Is a dedicated recipe needed, or would some general header-phi recipe/VPInstruction suffice?
(from https://reviews.llvm.org/D99750?id=558054#inline-1552139)

This would need a scalar phi and could share code with VPCanonicalIVPHIRecipe I think. I think this can be done as cleanup as follow-up, would be good to leave a TODO

https://github.com/llvm/llvm-project/pull/76172


More information about the llvm-commits mailing list