[llvm] [X86] Set default rounding mode round to nearest for llvm.set.rounding (PR #160823)
via llvm-commits
llvm-commits at lists.llvm.org
Fri Sep 26 00:49:11 PDT 2025
https://github.com/JaydeepChauhan14 created https://github.com/llvm/llvm-project/pull/160823
- Fix https://github.com/llvm/llvm-project/pull/156591#issuecomment-3335218842
- As per https://cdrdv2.intel.com/v1/dl/getContent/671200 default rounding mode is **round to nearest**.
>From 3d518a1e6dc65bcc0f091a1720ebddc8eaa832f8 Mon Sep 17 00:00:00 2001
From: Chauhan Jaydeep Ashwinbhai <chauhan.jaydeep.ashwinbhai at intel.com>
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 {
More information about the llvm-commits
mailing list