[llvm] [VPlan] Add new VPInstruction ocpode for header mask. (PR #89603)
via llvm-commits
llvm-commits at lists.llvm.org
Mon May 6 03:45:44 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:
(Following discussion w/ @aniragil): rather than introduce a designated abstract VPInstruction, suffice for a loop region::getHeaderMask() to provide a VPValue*, initially an instance of VPValue it holds - as an abstract "live-in", until replaced by a (concrete) recipe - ActiveLaneMask or a vector compare? This replacement can be done via setHeaderMask(). Whoever needs access to the canonical IV can get it directly rather than check the header mask's operand. Whoever materializes concrete recipes for generating the header mask can figure out where to place them directly, rather than use the abstract header mask as a concrete insertion point.
For EVL, setHeaderMask() effectively sets the header mask to null, after visiting all its users.
https://github.com/llvm/llvm-project/pull/89603
More information about the llvm-commits
mailing list