[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:29:08 PDT 2024


================
@@ -7104,6 +7122,33 @@ bool AMDGPULegalizerInfo::legalizeFPTruncRound(MachineInstr &MI,
   return true;
 }
 
+bool AMDGPULegalizerInfo::legalizeLROUND(MachineInstr &MI,
+                                         MachineRegisterInfo &MRI,
+                                         MachineIRBuilder &B) const {
+  Register DstReg = MI.getOperand(0).getReg();
+  Register SrcReg = MI.getOperand(1).getReg();
+  LLT SrcTy = MRI.getType(SrcReg);
+
+  auto Round = B.buildInstr(TargetOpcode::G_INTRINSIC_ROUND, {SrcTy}, {SrcReg});
+  B.buildFPTOSI(DstReg, Round);
+  MI.eraseFromParent();
+  return true;
+}
+
+bool AMDGPULegalizerInfo::legalizeLRINT(MachineInstr &MI,
----------------
arsenm wrote:

This should go in LegalizerHelper and be the default lower implementation. There's nothing AMDGPU specific here 

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


More information about the llvm-commits mailing list