[llvm] [AMDGPU] PromoteAlloca: reject known out-of-bounds index (PR #139700)
Matt Arsenault via llvm-commits
llvm-commits at lists.llvm.org
Tue May 13 06:27:15 PDT 2025
================
@@ -920,6 +919,12 @@ bool AMDGPUPromoteAllocaImpl::tryPromoteAllocaToVector(AllocaInst &Alloca) {
Value *Index = GEPToVectorIndex(GEP, &Alloca, VecEltTy, *DL, NewGEPInsts);
if (!Index)
return RejectUser(Inst, "cannot compute vector index for GEP");
+ // Alternatively, if there is a constant index for which we already know
+ // that it will be out-of-bounds, we also don't want to promote this
+ // alloca to vector.
+ if (ConstantInt *I = dyn_cast<ConstantInt>(Index);
+ I && I->getZExtValue() >= Alloca.getAllocationSize(*DL))
+ return RejectUser(Inst, "GEP constant index out-of-bounds");
----------------
arsenm wrote:
There's no reason to reject it, and you should proceed. The out of bounds index will just produce a poison value in the vector indexing
https://github.com/llvm/llvm-project/pull/139700
More information about the llvm-commits
mailing list