[llvm] [VPlan] Add new VPInstruction ocpode for header mask. (PR #89603)

via llvm-commits llvm-commits at lists.llvm.org
Wed May 1 10:09:55 PDT 2024


================
@@ -1203,52 +1164,32 @@ static VPActiveLaneMaskPHIRecipe *addVPLaneMaskPhiAndUpdateExitBranch(
   return LaneMaskPhi;
 }
 
-/// Collect all VPValues representing a header mask through the (ICMP_ULE,
-/// WideCanonicalIV, backedge-taken-count) pattern.
-/// TODO: Introduce explicit recipe for header-mask instead of searching
-/// for the header-mask pattern manually.
-static SmallVector<VPValue *> collectAllHeaderMasks(VPlan &Plan) {
-  SmallVector<VPValue *> WideCanonicalIVs;
-  auto *FoundWidenCanonicalIVUser =
-      find_if(Plan.getCanonicalIV()->users(),
-              [](VPUser *U) { return isa<VPWidenCanonicalIVRecipe>(U); });
-  assert(count_if(Plan.getCanonicalIV()->users(),
-                  [](VPUser *U) { return isa<VPWidenCanonicalIVRecipe>(U); }) <=
-             1 &&
-         "Must have at most one VPWideCanonicalIVRecipe");
-  if (FoundWidenCanonicalIVUser != Plan.getCanonicalIV()->users().end()) {
-    auto *WideCanonicalIV =
-        cast<VPWidenCanonicalIVRecipe>(*FoundWidenCanonicalIVUser);
-    WideCanonicalIVs.push_back(WideCanonicalIV);
-  }
-
-  // Also include VPWidenIntOrFpInductionRecipes that represent a widened
-  // version of the canonical induction.
+/// Return the header mask recipe of the VPlan, if there is one.
+static VPInstruction *getHeaderMask(VPlan &Plan) {
----------------
ayalz wrote:

Some thoughts: have Loop Region (1) provide a getHeaderMask() method which (always) returns a VPValue* (2) hold an abstract HeaderMask VPInstruction* field. The former retrieves the latter initially, later retrieves concrete header mask generating recipe. The latter should be unique per loop region. It may be inserted into the header VPBB (after canonical IV recipe) if needed to make sure standard def/use dominance relations are in tact(?) but in general it also represents a bump which is placed after (header) phi's, and must not be executed, so better have the region take care of (printing) it?
Similar argument applies to the canonical IV, if/when introduced initially w/o its bump, to be lowered eventually to a regular induction header phi and add recipes.

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


More information about the llvm-commits mailing list