[llvm] [VPlan] Create AVL as a phi from TC -> 0 with EVL tail folding (PR #151481)

Luke Lau via llvm-commits llvm-commits at lists.llvm.org
Thu Jul 31 03:04:05 PDT 2025


================
@@ -2379,6 +2381,11 @@ bool VPlanTransforms::tryAddExplicitVectorLength(
       CanonicalIVIncrement->getDebugLoc(), "index.evl.next");
   EVLPhi->addOperand(NextEVLIV);
 
+  VPValue *NextAVL = Builder.createOverflowingOp(
+      Instruction::Sub, {AVLPhi, OpVPEVL}, {/*hasNUW=*/true, /*hasNSW=*/false},
----------------
lukel97 wrote:

AFAIK the trip count is always an unsigned integer, and we're decrementing it downwards towards zero by EVL each time.

EVL should never be larger than the original trip count so it should never have unsigned wrap.

I didn't add nsw because I think we can go from SINT_MIN to e.g. SINT_MIN-1 which wraps

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


More information about the llvm-commits mailing list