From 3d518a1e6dc65bcc0f091a1720ebddc8eaa832f8 Mon Sep 17 00:00:00 2001 From: Chauhan Jaydeep Ashwinbhai Date: Fri, 26 Sep 2025 00:46:01 -0700 Subject: [PATCH] [X86] Set default rounding mode round to nearest for llvm.set.rounding --- llvm/lib/Target/X86/GISel/X86LegalizerInfo.cpp | 1 + llvm/lib/Target/X86/X86ISelLowering.cpp | 2 +- 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/llvm/lib/Target/X86/GISel/X86LegalizerInfo.cpp b/llvm/lib/Target/X86/GISel/X86LegalizerInfo.cpp index ee9760f881ae9..143c4c43e611a 100644 --- a/llvm/lib/Target/X86/GISel/X86LegalizerInfo.cpp +++ b/llvm/lib/Target/X86/GISel/X86LegalizerInfo.cpp @@ -905,6 +905,7 @@ bool X86LegalizerInfo::legalizeSETROUNDING(MachineInstr &MI, int FieldVal = X86::getRoundingModeX86(RM); if (FieldVal == X86::rmInvalid) { + FieldVal = X86::rmToNearest; LLVMContext &C = MF.getFunction().getContext(); C.diagnose(DiagnosticInfoUnsupported( MF.getFunction(), "rounding mode is not supported by X86 hardware", diff --git a/llvm/lib/Target/X86/X86ISelLowering.cpp b/llvm/lib/Target/X86/X86ISelLowering.cpp index 80fbcaa562032..57cf66e5275e3 100644 --- a/llvm/lib/Target/X86/X86ISelLowering.cpp +++ b/llvm/lib/Target/X86/X86ISelLowering.cpp @@ -28714,11 +28714,11 @@ SDValue X86TargetLowering::LowerSET_ROUNDING(SDValue Op, int FieldVal = X86::getRoundingModeX86(RM); if (FieldVal == X86::rmInvalid) { + FieldVal = X86::rmToNearest; LLVMContext &C = MF.getFunction().getContext(); C.diagnose(DiagnosticInfoUnsupported( MF.getFunction(), "rounding mode is not supported by X86 hardware", DiagnosticLocation(DL.getDebugLoc()), DS_Error)); - return {}; } RMBits = DAG.getConstant(FieldVal, DL, MVT::i16); } else {