[llvm-branch-commits] [llvm] [SPIRV] Do not eliminate `OpPointerType` even if unused (PR #182551)

Juan Manuel Martinez CaamaƱo via llvm-branch-commits llvm-branch-commits at lists.llvm.org
Mon Feb 23 06:45:39 PST 2026


jmmartinez wrote:

> One of the reasons I added the code to remove the unused types is because keeping the types around can cause invalid SPIR-V.
> 
> For example, the llvm-ir may contain vectors with a large number of elements that then gets legalized. If we do not remove long vector type, then the spir-v will not validate.
> 
> This PR could indirectly keep the invalid types around. If there is a pointer to a longer vector type, then the pointer type will be kept, and so will the vector type.
> 
> Can you describe what other solutions you considered? We should try to move away from keeping instructions around because they may get used, and creating the instructions when they are needed if they do not exist.



> One of the reasons I added the code to remove the unused types is because keeping the types around can cause invalid SPIR-V.
> 
> For example, the llvm-ir may contain vectors with a large number of elements that then gets legalized. If we do not remove long vector type, then the spir-v will not validate.
> 
> This PR could indirectly keep the invalid types around. If there is a pointer to a longer vector type, then the pointer type will be kept, and so will the vector type.
> 
> Can you describe what other solutions you considered? We should try to move away from keeping instructions around because they may get used, and creating the instructions when they are needed if they do not exist.

I hit the vector of 16 elements recently XD .

My current idea is to keep the state of `VRegToTypeMap` as implicit uses of the instructions. The advantage of doing that is that `VRegToTypeMap` would become explicit in the intermediate representation.

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


More information about the llvm-branch-commits mailing list