[llvm] [AMDGPU] Enable i8 GEP promotion for vector allocas (PR #166132)

Harrison Hao via llvm-commits llvm-commits at lists.llvm.org
Mon Nov 3 22:58:55 PST 2025


================
@@ -456,10 +456,21 @@ static Value *GEPToVectorIndex(GetElementPtrInst *GEP, AllocaInst *Alloca,
   const auto &VarOffset = VarOffsets.front();
   APInt OffsetQuot;
   APInt::sdivrem(VarOffset.second, VecElemSize, OffsetQuot, Rem);
-  if (Rem != 0 || OffsetQuot.isZero())
-    return nullptr;
+
+  Value *Scaled = nullptr;
+  if (Rem != 0 || OffsetQuot.isZero()) {
+    unsigned ElemSizeShift = Log2_64(VecElemSize);
----------------
harrisonGPU wrote:

Thanks, but I think it is not necessary to explicitly check whether the element size is a power of two, because it is already covered by the existing check here:
https://github.com/llvm/llvm-project/blob/52fdcf94a39a811476654e23176c6ffa69ff7287/llvm/lib/Target/AMDGPU/AMDGPUPromoteAlloca.cpp#L871-L877

If the element type is not naturally aligned, it will return false, which also rejects non power of 2 element sizes, such as i24.

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


More information about the llvm-commits mailing list