[llvm] [SDAG][NVPTX] Add TLI check for preferring custom FP_TO_SINT operations to FP_TO_UINT (PR #132470)
Artem Belevich via llvm-commits
llvm-commits at lists.llvm.org
Tue Mar 25 14:22:43 PDT 2025
================
@@ -6179,6 +6179,33 @@ Instruction *NVPTXTargetLowering::emitTrailingFence(IRBuilderBase &Builder,
return nullptr;
}
+// Rather than default to SINT when both UINT and SINT are custom, we only
+// change the opcode when UINT is not legal and SINT is. UINT is preferred when
+// both are custom since unsigned CVT instructions can lead to slightly better
+// SASS code with fewer instructions.
+unsigned NVPTXTargetLowering::getFPToXIntOpcode(unsigned Op, EVT FromVT,
----------------
Artem-B wrote:
Do we need to override it for NVPTX then? It sounds like the default implementation would do the job. Reading the original comment in PromoteIntRes_FP_TO_XINT it may be PPC that would need the override.
Given that we did end up with the signed conversion, I suspect NVPTX's problem is not whether we want to pick signed or unsigned conversion, but that we need to extend the set of supported conversions to cover "{f16,f32,f64} <-> u8", possibly to other integer types, too. Then we'd always end up with signedness-matching conversion instruction. Right now we only define them for i1, i16, i32 and i64, but not i8.
https://github.com/llvm/llvm-project/blob/2f3c93743fc21686158c9ba51da8f25da9a02f9d/llvm/lib/Target/NVPTX/NVPTXISelLowering.cpp#L896-L900
https://github.com/llvm/llvm-project/pull/132470
More information about the llvm-commits
mailing list