Skip to content

Commit 776aef1

Browse files
committed
[RISCV] Correct the rounding mode for llvm.lround.i64.f32 with RV64+Zfinx.
We should use RMM instead of DYN.
1 parent 747d89a commit 776aef1

File tree

3 files changed

+6
-6
lines changed

3 files changed

+6
-6
lines changed

llvm/lib/Target/RISCV/RISCVInstrInfoF.td

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -799,8 +799,8 @@ def : Pat<(i64 (any_lrint FPR32INX:$rs1)), (FCVT_L_S_INX $rs1, FRM_DYN)>;
799799
def : Pat<(i64 (any_llrint FPR32INX:$rs1)), (FCVT_L_S_INX $rs1, FRM_DYN)>;
800800

801801
// float->int64 rounded to neartest with ties rounded away from zero.
802-
def : Pat<(i64 (any_lround FPR32INX:$rs1)), (FCVT_L_S_INX $rs1, FRM_DYN)>;
803-
def : Pat<(i64 (any_llround FPR32INX:$rs1)), (FCVT_L_S_INX $rs1, FRM_DYN)>;
802+
def : Pat<(i64 (any_lround FPR32INX:$rs1)), (FCVT_L_S_INX $rs1, FRM_RMM)>;
803+
def : Pat<(i64 (any_llround FPR32INX:$rs1)), (FCVT_L_S_INX $rs1, FRM_RMM)>;
804804

805805
// [u]int->fp. Match GCC and default to using dynamic rounding mode.
806806
def : Pat<(any_sint_to_fp (i64 (sexti32 (i64 GPR:$rs1)))), (FCVT_S_W_INX $rs1, FRM_DYN)>;

llvm/test/CodeGen/RISCV/float-intrinsics-strict.ll

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1473,7 +1473,7 @@ define iXLen @lround_f32(float %a) nounwind strictfp {
14731473
;
14741474
; RV64IZFINX-LABEL: lround_f32:
14751475
; RV64IZFINX: # %bb.0:
1476-
; RV64IZFINX-NEXT: fcvt.l.s a0, a0
1476+
; RV64IZFINX-NEXT: fcvt.l.s a0, a0, rmm
14771477
; RV64IZFINX-NEXT: ret
14781478
;
14791479
; RV32I-LABEL: lround_f32:
@@ -1577,7 +1577,7 @@ define i64 @llround_f32(float %a) nounwind strictfp {
15771577
;
15781578
; RV64IZFINX-LABEL: llround_f32:
15791579
; RV64IZFINX: # %bb.0:
1580-
; RV64IZFINX-NEXT: fcvt.l.s a0, a0
1580+
; RV64IZFINX-NEXT: fcvt.l.s a0, a0, rmm
15811581
; RV64IZFINX-NEXT: ret
15821582
;
15831583
; RV32I-LABEL: llround_f32:

llvm/test/CodeGen/RISCV/float-intrinsics.ll

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1445,7 +1445,7 @@ define iXLen @lround_f32(float %a) nounwind {
14451445
;
14461446
; RV64IZFINX-LABEL: lround_f32:
14471447
; RV64IZFINX: # %bb.0:
1448-
; RV64IZFINX-NEXT: fcvt.l.s a0, a0
1448+
; RV64IZFINX-NEXT: fcvt.l.s a0, a0, rmm
14491449
; RV64IZFINX-NEXT: ret
14501450
;
14511451
; RV32I-LABEL: lround_f32:
@@ -1593,7 +1593,7 @@ define i64 @llround_f32(float %a) nounwind {
15931593
;
15941594
; RV64IZFINX-LABEL: llround_f32:
15951595
; RV64IZFINX: # %bb.0:
1596-
; RV64IZFINX-NEXT: fcvt.l.s a0, a0
1596+
; RV64IZFINX-NEXT: fcvt.l.s a0, a0, rmm
15971597
; RV64IZFINX-NEXT: ret
15981598
;
15991599
; RV32I-LABEL: llround_f32:

0 commit comments

Comments
 (0)