[llvm] [VPlan] Fix header masks in EVL tail folding (PR #150202)

Florian Hahn via llvm-commits llvm-commits at lists.llvm.org
Wed Jul 23 05:40:34 PDT 2025


================
@@ -2265,6 +2269,27 @@ static void transformRecipestoEVLRecipes(VPlan &Plan, VPValue &EVL) {
     for (VPValue *Op : PossiblyDead)
       recursivelyDeleteDeadRecipes(Op);
   }
+
+  // Replace header masks with a mask equivalent to predicating by EVL:
+  //
+  // icmp ule widen-canonical-iv backedge-taken-count
+  // ->
+  // icmp ult step-vector, EVL
+  Type *EVLType = TypeInfo.inferScalarType(&EVL);
----------------
fhahn wrote:

So this is needed for correctness, right? Should it not happen before the loop above?

Also, inferring type after removing recipes? Should this happen before `for (VPRecipeBase *R : reverse(ToErase)) {`?

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


More information about the llvm-commits mailing list