[llvm] [AMDGPU] Add support for llvm.lround and llvm.lrint intrinsics lowering. (PR #96817)

Matt Arsenault via llvm-commits llvm-commits at lists.llvm.org
Thu Jun 27 00:21:37 PDT 2024


================
@@ -2493,6 +2502,14 @@ SDValue AMDGPUTargetLowering::LowerFRINT(SDValue Op, SelectionDAG &DAG) const {
   return DAG.getNode(ISD::FROUNDEVEN, SDLoc(Op), VT, Arg);
 }
 
+SDValue AMDGPUTargetLowering::LowerLRINT(SDValue Op, SelectionDAG &DAG) const {
+  auto ResVT = Op.getValueType();
+  auto Arg = Op.getOperand(0u);
+  auto ArgVT = Arg.getValueType();
+  SDValue RoundNode = DAG.getNode(ISD::FROUNDEVEN, SDLoc(Op), ArgVT, Arg);
+  return DAG.getNode(ISD::FP_TO_SINT, SDLoc(Op), ResVT, RoundNode);
----------------
arsenm wrote:

Hmm, this is what musl does for the lround case (with an implicit cast, gross)
https://git.musl-libc.org/cgit/musl/tree/src/math/lround.c

But the lower lrint case is more complicated:
https://git.musl-libc.org/cgit/musl/tree/src/math/lrint.c

Can you split the PR into one for each intrinsic? (plus another for the verifier changes) 

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


More information about the llvm-commits mailing list