[llvm] [AMDGPU] Improved Lowering of abs(i16) and -abs(i16) (PR #165626)
Matt Arsenault via llvm-commits
llvm-commits at lists.llvm.org
Fri Oct 31 23:00:14 PDT 2025
arsenm wrote:
> so how would I go about checking whether the input is divergent?
Like [this](https://github.com/llvm/llvm-project/blob/605a7d65340935816b420d034173aee34029a215/llvm/lib/Target/AMDGPU/SIISelLowering.cpp#L7966)
> @arsenm also am I making the lowering "custom for i16" properly in that commit, or is there another way? It bugged me that I had to make that function virtual to override it since I thought, if this was the right way to go, some other target probably would have made it virtual by now.
No, you shouldn't need to make anything virtual. You should call `setOperationAction(ISD::ABS, MVT::i16, Legal)` under `Subtarget->has16BitInsts()` in the SITargetLowering constructor. In the handling in LowerOperation, you can defer to the default expansion (by returning either SDValue(), or the original SDValue). One of them is the take as directly legal, the other is take as use default expansion but I can never remember which is which
https://github.com/llvm/llvm-project/pull/165626
More information about the llvm-commits
mailing list