[llvm] [AMDGPU] Implement llvm.fptosi.sat and llvm.fptoui.sat (PR #174726)
Carl Ritson via llvm-commits
llvm-commits at lists.llvm.org
Thu Jan 22 00:55:38 PST 2026
================
@@ -3762,6 +3767,52 @@ SDValue AMDGPUTargetLowering::LowerFP_TO_INT(const SDValue Op,
return SDValue();
}
+SDValue AMDGPUTargetLowering::LowerFP_TO_INT_SAT(const SDValue Op,
----------------
perlfu wrote:
`expandFP_TO_INT_SAT` implements saturation using FP_TO_INT assuming it does not saturate directly; hence it inserts comparisons and selects with lower and upper bounds of floating point to (u)int range, preserving NaN, etc.
None of which is required when we have direct support for this in hardware.
However, we do not have dedicated saturating instructions (creates some selection issues) and only support conversion over a limited set of input/output types.
This implementation is concerned with pack/unpacking saturated conversion though the limited set of conversion instructions we do have.
https://github.com/llvm/llvm-project/pull/174726
More information about the llvm-commits
mailing list