Skip to content

Commit 03fc4f2

Browse files
committed
[RISCV] Use fcvt.h/d/f.w if the input is an assertsexti32 not just when the input is sext_inreg.
1 parent 3242eae commit 03fc4f2

File tree

6 files changed

+6
-6
lines changed

6 files changed

+6
-6
lines changed

llvm/lib/Target/RISCV/RISCVInstrInfoD.td

+1-1
Original file line numberDiff line numberDiff line change
@@ -373,7 +373,7 @@ def : Pat<(sext_inreg (assertzexti32 (fp_to_uint FPR64:$rs1)), i32),
373373
(FCVT_WU_D $rs1, 0b001)>;
374374

375375
// [u]int32->fp
376-
def : Pat<(sint_to_fp (sext_inreg GPR:$rs1, i32)), (FCVT_D_W $rs1)>;
376+
def : Pat<(sint_to_fp (sexti32 GPR:$rs1)), (FCVT_D_W $rs1)>;
377377
def : Pat<(uint_to_fp (zexti32 GPR:$rs1)), (FCVT_D_WU $rs1)>;
378378

379379
def : Pat<(fp_to_sint FPR64:$rs1), (FCVT_L_D FPR64:$rs1, 0b001)>;

llvm/lib/Target/RISCV/RISCVInstrInfoF.td

+1-1
Original file line numberDiff line numberDiff line change
@@ -417,7 +417,7 @@ def : Pat<(fp_to_sint FPR32:$rs1), (FCVT_L_S $rs1, 0b001)>;
417417
def : Pat<(fp_to_uint FPR32:$rs1), (FCVT_LU_S $rs1, 0b001)>;
418418

419419
// [u]int->fp. Match GCC and default to using dynamic rounding mode.
420-
def : Pat<(sint_to_fp (sext_inreg GPR:$rs1, i32)), (FCVT_S_W $rs1, 0b111)>;
420+
def : Pat<(sint_to_fp (sexti32 GPR:$rs1)), (FCVT_S_W $rs1, 0b111)>;
421421
def : Pat<(uint_to_fp (zexti32 GPR:$rs1)), (FCVT_S_WU $rs1, 0b111)>;
422422
def : Pat<(sint_to_fp GPR:$rs1), (FCVT_S_L $rs1, 0b111)>;
423423
def : Pat<(uint_to_fp GPR:$rs1), (FCVT_S_LU $rs1, 0b111)>;

llvm/lib/Target/RISCV/RISCVInstrInfoZfh.td

+1-1
Original file line numberDiff line numberDiff line change
@@ -374,7 +374,7 @@ def : Pat<(fp_to_sint FPR16:$rs1), (FCVT_L_H $rs1, 0b001)>;
374374
def : Pat<(fp_to_uint FPR16:$rs1), (FCVT_LU_H $rs1, 0b001)>;
375375

376376
// [u]int->fp. Match GCC and default to using dynamic rounding mode.
377-
def : Pat<(sint_to_fp (sext_inreg GPR:$rs1, i32)), (FCVT_H_W $rs1, 0b111)>;
377+
def : Pat<(sint_to_fp (sexti32 GPR:$rs1)), (FCVT_H_W $rs1, 0b111)>;
378378
def : Pat<(uint_to_fp (zexti32 GPR:$rs1)), (FCVT_H_WU $rs1, 0b111)>;
379379
def : Pat<(sint_to_fp GPR:$rs1), (FCVT_H_L $rs1, 0b111)>;
380380
def : Pat<(uint_to_fp GPR:$rs1), (FCVT_H_LU $rs1, 0b111)>;

llvm/test/CodeGen/RISCV/rv64d-double-convert.ll

+1-1
Original file line numberDiff line numberDiff line change
@@ -112,7 +112,7 @@ define double @sitofp_aext_i32_to_f64(i32 %a) nounwind {
112112
define double @sitofp_sext_i32_to_f64(i32 signext %a) nounwind {
113113
; RV64ID-LABEL: sitofp_sext_i32_to_f64:
114114
; RV64ID: # %bb.0:
115-
; RV64ID-NEXT: fcvt.d.l ft0, a0
115+
; RV64ID-NEXT: fcvt.d.w ft0, a0
116116
; RV64ID-NEXT: fmv.x.d a0, ft0
117117
; RV64ID-NEXT: ret
118118
%1 = sitofp i32 %a to double

llvm/test/CodeGen/RISCV/rv64f-float-convert.ll

+1-1
Original file line numberDiff line numberDiff line change
@@ -169,7 +169,7 @@ define float @sitofp_aext_i32_to_f32(i32 %a) nounwind {
169169
define float @sitofp_sext_i32_to_f32(i32 signext %a) nounwind {
170170
; RV64IF-LABEL: sitofp_sext_i32_to_f32:
171171
; RV64IF: # %bb.0:
172-
; RV64IF-NEXT: fcvt.s.l ft0, a0
172+
; RV64IF-NEXT: fcvt.s.w ft0, a0
173173
; RV64IF-NEXT: fmv.x.w a0, ft0
174174
; RV64IF-NEXT: ret
175175
%1 = sitofp i32 %a to float

llvm/test/CodeGen/RISCV/rv64f-half-convert.ll

+1-1
Original file line numberDiff line numberDiff line change
@@ -155,7 +155,7 @@ define half @sitofp_aext_i32_to_f16(i32 %a) nounwind {
155155
define half @sitofp_sext_i32_to_f16(i32 signext %a) nounwind {
156156
; RV64IZFH-LABEL: sitofp_sext_i32_to_f16:
157157
; RV64IZFH: # %bb.0:
158-
; RV64IZFH-NEXT: fcvt.h.l fa0, a0
158+
; RV64IZFH-NEXT: fcvt.h.w fa0, a0
159159
; RV64IZFH-NEXT: ret
160160
%1 = sitofp i32 %a to half
161161
ret half %1

0 commit comments

Comments
 (0)