[llvm] [LV] Vectorize early exit loops with stores using masking (PR #178454)
Florian Hahn via llvm-commits
llvm-commits at lists.llvm.org
Wed Feb 4 02:20:12 PST 2026
================
@@ -76,6 +76,36 @@ typedef unsigned ID;
using VPlanPtr = std::unique_ptr<VPlan>;
+// Different methods of handling early exits.
+// If one of the masked styles is chosen, all memory operations besides the
+// load(s) required to determine whether an uncountable exit occurred will be
+// masked based on that condition. The difference is then between whether all
+// operations are carried out in the vector loop (which may require the
+// the creation of multiple masks, depending on where side effects occur), or
+// whether the vector loop masks off the lane which would exit and processes the
+// exit in a single iteration of the scalar loop.
+//
+// The UnmaskedHandleLastVectorInScalarLoop style doesn't require masking, but
+// must determine whether there would be an exit in the next vector iteration,
+// and if so lets the scalar loop handle all remaining iterations. This does
+// require replicating the IR for all uncountable exits in a pre-header check
+// block to see if the first vector iteration would encounter the exit, and
+// within the vector loop the values for the next vector iteration must be
+// loaded instead.
+//
+// For ReadOnlyUncountableExitsInVectorLoop, there are no side effects to worry
+// about, so we can instead process any uncountable exit inside the vector
+// body and branch to an appropriate exit block, matching the behaviour of the
+// scalar loop.
+namespace EarlyExitStyleTy {
+enum Option {
+ MaskedHandleLastIterationInScalarLoop = 0,
+ MaskedHandleAllIterationsInVectorLoop,
+ UnmaskedHandleLastVectorInScalarLoop,
----------------
fhahn wrote:
Both never set?
https://github.com/llvm/llvm-project/pull/178454
More information about the llvm-commits
mailing list