This patch adds a NeedsMaskForGaps field to VPInterleaveRecipe to record
whether a mask for gaps is needed. This removes a dependence on the cost
model in VPlan code-generation.
Details
Diff Detail
- Repository
- rG LLVM Github Monorepo
Event Timeline
Whether masking of suffix gaps in interleaved loads can be optimized away or not should indeed be recorded during planning rather than IR generation.
Adding a couple of nits.
llvm/lib/Transforms/Vectorize/LoopVectorize.cpp | ||
---|---|---|
2670–2671 | nit (Independent of this patch): MaskForGaps is set here for loads and later reset for stores. Better to either set it here for both or place this setting inside the handling of loads. | |
9041 | nit: may be clearer to first set bool NeedsMaskForGaps = IG->requiresScalarEpilogue() && !CM.isScalarEpilogueAllowed(); and then use it, instead of setting it inline. | |
llvm/lib/Transforms/Vectorize/VPlan.h | ||
1398 | nit: would be good to document and clarify or rename the two masks: HasMask indicates if the interleave group is inside a conditional basic block, i.e., HasBlockMask or HasMaskForBlock. NeedsMaskForGaps indicates if the interleave group of loads is allowed to speculatively load absent unused members or must avoid doing so by using a mask, i.e., !CanSpeculativelyLoadWithoutMask, where the speculation relies on loading present members on both sides of missing ones - gaps. |
llvm/lib/Transforms/Vectorize/LoopVectorize.cpp | ||
---|---|---|
2670–2671 | Moved inside the load handling: 3f36b9b456ac4bfa695e253926daa87cd9838550 | |
9041 | Should be adjusted, thanks! | |
llvm/lib/Transforms/Vectorize/VPlan.h | ||
1398 | Added comments, thanks! |
nit (Independent of this patch): MaskForGaps is set here for loads and later reset for stores. Better to either set it here for both or place this setting inside the handling of loads.