[llvm-branch-commits] [llvm] AMDGPU/PromoteAlloca: Always use i32 for indexing (PR #170511)

Fabian Ritter via llvm-branch-commits llvm-branch-commits at lists.llvm.org
Thu Dec 4 00:57:12 PST 2025


================
@@ -461,22 +461,23 @@ static Value *GEPToVectorIndex(GetElementPtrInst *GEP, AllocaInst *Alloca,
     return nullptr;
 
   Value *Offset = VarOffset.first;
-  auto *OffsetType = dyn_cast<IntegerType>(Offset->getType());
-  if (!OffsetType)
+  if (!isa<IntegerType>(Offset->getType()))
     return nullptr;
 
+  Offset = Builder.CreateSExtOrTrunc(Offset, Builder.getIntNTy(BW));
----------------
ritter-x2a wrote:

This patch changed it to signed: https://github.com/llvm/llvm-project/pull/157682
Before that, the unsigned treatment caused a bug: https://github.com/llvm/llvm-project/pull/155415#issuecomment-3244625707
GEPs with negative 32-bit indices were promoted into broken 64-bit extract-element indices.

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


More information about the llvm-branch-commits mailing list