Skip to content

Commit

Permalink
[RISCV] Correct the rounding mode for llvm.lround.i64.f32 with RV64+Z…
Browse files Browse the repository at this point in the history
…finx.

We should use RMM instead of DYN.
  • Loading branch information
topperc committed Sep 1, 2024
1 parent 747d89a commit 776aef1
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 6 deletions.
4 changes: 2 additions & 2 deletions llvm/lib/Target/RISCV/RISCVInstrInfoF.td
Original file line number Diff line number Diff line change
Expand Up @@ -799,8 +799,8 @@ def : Pat<(i64 (any_lrint FPR32INX:$rs1)), (FCVT_L_S_INX $rs1, FRM_DYN)>;
def : Pat<(i64 (any_llrint FPR32INX:$rs1)), (FCVT_L_S_INX $rs1, FRM_DYN)>;

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

// [u]int->fp. Match GCC and default to using dynamic rounding mode.
def : Pat<(any_sint_to_fp (i64 (sexti32 (i64 GPR:$rs1)))), (FCVT_S_W_INX $rs1, FRM_DYN)>;
Expand Down
4 changes: 2 additions & 2 deletions llvm/test/CodeGen/RISCV/float-intrinsics-strict.ll
Original file line number Diff line number Diff line change
Expand Up @@ -1473,7 +1473,7 @@ define iXLen @lround_f32(float %a) nounwind strictfp {
;
; RV64IZFINX-LABEL: lround_f32:
; RV64IZFINX: # %bb.0:
; RV64IZFINX-NEXT: fcvt.l.s a0, a0
; RV64IZFINX-NEXT: fcvt.l.s a0, a0, rmm
; RV64IZFINX-NEXT: ret
;
; RV32I-LABEL: lround_f32:
Expand Down Expand Up @@ -1577,7 +1577,7 @@ define i64 @llround_f32(float %a) nounwind strictfp {
;
; RV64IZFINX-LABEL: llround_f32:
; RV64IZFINX: # %bb.0:
; RV64IZFINX-NEXT: fcvt.l.s a0, a0
; RV64IZFINX-NEXT: fcvt.l.s a0, a0, rmm
; RV64IZFINX-NEXT: ret
;
; RV32I-LABEL: llround_f32:
Expand Down
4 changes: 2 additions & 2 deletions llvm/test/CodeGen/RISCV/float-intrinsics.ll
Original file line number Diff line number Diff line change
Expand Up @@ -1445,7 +1445,7 @@ define iXLen @lround_f32(float %a) nounwind {
;
; RV64IZFINX-LABEL: lround_f32:
; RV64IZFINX: # %bb.0:
; RV64IZFINX-NEXT: fcvt.l.s a0, a0
; RV64IZFINX-NEXT: fcvt.l.s a0, a0, rmm
; RV64IZFINX-NEXT: ret
;
; RV32I-LABEL: lround_f32:
Expand Down Expand Up @@ -1593,7 +1593,7 @@ define i64 @llround_f32(float %a) nounwind {
;
; RV64IZFINX-LABEL: llround_f32:
; RV64IZFINX: # %bb.0:
; RV64IZFINX-NEXT: fcvt.l.s a0, a0
; RV64IZFINX-NEXT: fcvt.l.s a0, a0, rmm
; RV64IZFINX-NEXT: ret
;
; RV32I-LABEL: llround_f32:
Expand Down

0 comments on commit 776aef1

Please sign in to comment.