[llvm] [CodeGen] Make LoadExtActions address-space aware (PR #162407)
Demetrius Kanios via llvm-commits
llvm-commits at lists.llvm.org
Wed Oct 8 12:05:57 PDT 2025
QuantumSegfault wrote:
Besides avoiding touching the backends, the overrides idea makes it easier when a given backend DOES want to override ALL addressspaces (like AMDGPU). Avoids having to loop over all (relevant) address-spaces just to set the same behavior (see my changes to the AMDGPU backend... :/)
> Like, are there any targets that could use both versions together, or would they all just use one or the other?
I'm not entirely sure. There doesn't seem to be many backends making heavy use of address spaces; mainly NVPTX, AMDGPU, and WebAssembly.
I did notice this when fixing up AMDGPU:
https://github.com/llvm/llvm-project/blob/81c6f53c19cd29c401355a1c5764b35bfdea6164/llvm/lib/Target/AMDGPU/R600ISelLowering.cpp#L48-L55
Main AMDGPU sets these `i8` and `i16` extending loads legal, but then the R600 subtarget marks them custom. The specific address spaces needing Custom handling could be marked as such with the new override mechanism, while AMDGPU as a whole keeps the original API. Though whether this would provide any tangible benefit is unclear. It may allow some better optimization in some cases that are being blocked right now by unnecessary "Custom"? The very reason we went down this rabbit hole to begin with.
-------
Also, a override mechanism would prevent this from needing to be put in here (this was moved from `TargetLoweringBase::initActions`)
https://github.com/llvm/llvm-project/blob/ebcf9ba3a60dbc7475e3eaf132d53282d3a304b7/llvm/include/llvm/CodeGen/TargetLowering.h#L2653-L2662
-------
I'm currently putting the finishing touches on the overrides concept, so I'll push that shortly and you can see which seems more ideal.
https://github.com/llvm/llvm-project/pull/162407
More information about the llvm-commits
mailing list