[llvm] [LV] Preserve GEP nusw when widening memory (PR #160885)

Luke Lau via llvm-commits llvm-commits at lists.llvm.org
Fri Sep 26 08:42:52 PDT 2025


================
@@ -7482,12 +7482,11 @@ VPRecipeBuilder::tryToWidenMemory(Instruction *I, ArrayRef<VPValue *> Operands,
     VPSingleDefRecipe *VectorPtr;
     if (Reverse) {
       // When folding the tail, we may compute an address that we don't in the
-      // original scalar loop and it may not be inbounds. Drop Inbounds in that
-      // case.
+      // original scalar loop: use none in this case.
       GEPNoWrapFlags Flags =
-          (CM.foldTailByMasking() || !GEP || !GEP->isInBounds())
+          CM.foldTailByMasking() || !GEP
               ? GEPNoWrapFlags::none()
-              : GEPNoWrapFlags::inBounds();
+              : GEP->getNoWrapFlags().withoutNoUnsignedWrap();
----------------
lukel97 wrote:

Oh I see, and we only preserve it when we're not tail folding. So all the computed range would have been covered in the scalar loop. 

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


More information about the llvm-commits mailing list