[llvm] [LV, VPlan] Check if plan is compatible to EVL transform (PR #92092)

Florian Hahn via llvm-commits llvm-commits at lists.llvm.org
Tue May 14 06:30:54 PDT 2024


================
@@ -8539,6 +8539,29 @@ VPRecipeBuilder::tryToCreateWidenRecipe(Instruction *Instr,
   return tryToWiden(Instr, Operands, VPBB);
 }
 
+// EVL transform doesn't support backends where EVL diffs from RuntimeVF
+// in the second-to-last iteration.
+// Return false if the vector region has recipes relying on
+// RuntimeVF.
+static bool isCompatibleToEVLTransform(VPlan &Plan) {
+  auto HasAnyRuntimeVFUserInLoop = [](VPlan &Plan) -> bool {
+    for (auto &Phi : Plan.getVectorLoopRegion()->getEntryBasicBlock()->phis())
+      if (isa<VPWidenIntOrFpInductionRecipe>(&Phi) ||
+          isa<VPWidenPointerInductionRecipe>(&Phi))
+        return true;
+    for (VPBasicBlock *VPBB : VPBlockUtils::blocksOnly<VPBasicBlock>(
+             vp_depth_first_deep(Plan.getVectorLoopRegion())))
+      for (VPRecipeBase &Recipe : *VPBB)
+        if (auto *VecPtrR = dyn_cast<VPVectorPointerRecipe>(&Recipe))
+          if (VecPtrR->isReverse())
+            return true;
+    return false;
+  };
+  if (HasAnyRuntimeVFUserInLoop(Plan))
----------------
fhahn wrote:

Simpler to not use the lambda but directly runtime from the loops in it?

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


More information about the llvm-commits mailing list