[llvm-branch-commits] [Vectorizer] fix GEPs incorrectly marked as "inbounds" (PR #120730)

Nikita Popov via llvm-branch-commits llvm-branch-commits at lists.llvm.org
Fri Dec 20 05:35:51 PST 2024


================
@@ -1986,10 +1986,12 @@ void VPReverseVectorPointerRecipe::execute(VPTransformState &State) {
   // LastLane = 1 - RunTimeVF
   Value *LastLane = Builder.CreateSub(ConstantInt::get(IndexTy, 1), RunTimeVF);
   Value *Ptr = State.get(getOperand(0), VPLane(0));
-  Value *ResultPtr =
-      Builder.CreateGEP(IndexedTy, Ptr, NumElt, "", getGEPNoWrapFlags());
-  ResultPtr = Builder.CreateGEP(IndexedTy, ResultPtr, LastLane, "",
-                                getGEPNoWrapFlags());
+  Value *ResultPtr = Builder.CreateGEP(
+      IndexedTy, Ptr, NumElt, "",
+      getGEPNoWrapFlags().withoutInBounds().withoutNoUnsignedSignedWrap());
+  ResultPtr = Builder.CreateGEP(
+      IndexedTy, ResultPtr, LastLane, "",
+      getGEPNoWrapFlags().withoutInBounds().withoutNoUnsignedSignedWrap());
----------------
nikic wrote:

Note that inbounds is the only flag that can be set for this recipe, see https://github.com/llvm/llvm-project/blob/a9034d0b7ff3b0bf90239f6b46ada7f3490b6904/llvm/lib/Transforms/Vectorize/LoopVectorize.cpp#L8441-L8442. So effectively this means that we never use flags here. It would be cleaner to not associate flags with this recipe in the first place, I think.

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


More information about the llvm-branch-commits mailing list