[llvm] [AMDGPU] Treat GEP offsets as signed in AMDGPUPromoteAlloca (PR #157682)

Nikita Popov via llvm-commits llvm-commits at lists.llvm.org
Tue Sep 9 08:00:15 PDT 2025


================
@@ -474,7 +477,7 @@ static Value *GEPToVectorIndex(GetElementPtrInst *GEP, AllocaInst *Alloca,
     return Offset;
 
   ConstantInt *ConstIndex =
-      ConstantInt::get(OffsetType, IndexQuot.getZExtValue());
+      ConstantInt::get(OffsetType, IndexQuot.getSExtValue());
   Value *IndexAdd = Builder.CreateAdd(ConstIndex, Offset);
----------------
nikic wrote:

Side note: Would be better to swap the operands here to generate the canonical form.

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


More information about the llvm-commits mailing list