[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:41 PDT 2025
llvmbot wrote:
<!--LLVM PR SUMMARY COMMENT-->
@llvm/pr-subscribers-backend-x86
Author: None (JaydeepChauhan14)
<details>
<summary>Changes</summary>
- 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**.
---
Full diff: https://github.com/llvm/llvm-project/pull/160823.diff
2 Files Affected:
- (modified) llvm/lib/Target/X86/GISel/X86LegalizerInfo.cpp (+1)
- (modified) llvm/lib/Target/X86/X86ISelLowering.cpp (+1-1)
``````````diff
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 {
``````````
</details>
https://github.com/llvm/llvm-project/pull/160823
More information about the llvm-commits
mailing list