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

Harrison Hao via llvm-commits llvm-commits at lists.llvm.org
Mon Nov 10 00:28:11 PST 2025


harrisonGPU wrote:

> > Could you please give me an example?
> 
> In the test case, the `%index` is for `%alloca` of `<3 x float>`, which is 12-byte, each of which has 4-byte. Since the GEP is of type `i8`, what if `%index` is 5, which will be somewhere in the middle of the 2nd element of `%alloca`.

Hi @shiltian , I’ve already thought about this issue — thank you very much for your suggestion and for pointing it out.
Now I think we should only promote when the variable index is guaranteed to be aligned to the element size.
We can use `computeKnownBits` and `countMinTrailingZeros` to check that the lower bits of the index are zero, which verifies its alignment before promoting.
I’ve updated the lit test and commit message accordingly. What do you think?

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


More information about the llvm-commits mailing list