diff --git a/llvm/lib/Target/RISCV/RISCVInstrInfoD.td b/llvm/lib/Target/RISCV/RISCVInstrInfoD.td --- a/llvm/lib/Target/RISCV/RISCVInstrInfoD.td +++ b/llvm/lib/Target/RISCV/RISCVInstrInfoD.td @@ -306,11 +306,15 @@ def : Pat<(seto FPR64:$rs1, FPR64:$rs2), (AND (FEQ_D FPR64:$rs1, FPR64:$rs1), (FEQ_D FPR64:$rs2, FPR64:$rs2))>; +def : Pat<(seto FPR64:$rs1, FPR64:$rs1), + (FEQ_D $rs1, $rs1)>; def : Pat<(setuo FPR64:$rs1, FPR64:$rs2), (SLTIU (AND (FEQ_D FPR64:$rs1, FPR64:$rs1), (FEQ_D FPR64:$rs2, FPR64:$rs2)), 1)>; +def : Pat<(setuo FPR64:$rs1, FPR64:$rs1), + (SLTIU (FEQ_D $rs1, $rs1), 1)>; def Select_FPR64_Using_CC_GPR : SelectCC_rrirr; diff --git a/llvm/lib/Target/RISCV/RISCVInstrInfoF.td b/llvm/lib/Target/RISCV/RISCVInstrInfoF.td --- a/llvm/lib/Target/RISCV/RISCVInstrInfoF.td +++ b/llvm/lib/Target/RISCV/RISCVInstrInfoF.td @@ -366,11 +366,15 @@ def : Pat<(seto FPR32:$rs1, FPR32:$rs2), (AND (FEQ_S FPR32:$rs1, FPR32:$rs1), (FEQ_S FPR32:$rs2, FPR32:$rs2))>; +def : Pat<(seto FPR32:$rs1, FPR32:$rs1), + (FEQ_S $rs1, $rs1)>; def : Pat<(setuo FPR32:$rs1, FPR32:$rs2), (SLTIU (AND (FEQ_S FPR32:$rs1, FPR32:$rs1), (FEQ_S FPR32:$rs2, FPR32:$rs2)), 1)>; +def : Pat<(setuo FPR32:$rs1, FPR32:$rs1), + (SLTIU (FEQ_S $rs1, $rs1), 1)>; def Select_FPR32_Using_CC_GPR : SelectCC_rrirr; diff --git a/llvm/test/CodeGen/RISCV/double-isnan.ll b/llvm/test/CodeGen/RISCV/double-isnan.ll --- a/llvm/test/CodeGen/RISCV/double-isnan.ll +++ b/llvm/test/CodeGen/RISCV/double-isnan.ll @@ -12,7 +12,6 @@ ; RV32IFD-NEXT: sw a1, 12(sp) ; RV32IFD-NEXT: fld ft0, 8(sp) ; RV32IFD-NEXT: feq.d a0, ft0, ft0 -; RV32IFD-NEXT: and a0, a0, a0 ; RV32IFD-NEXT: seqz a0, a0 ; RV32IFD-NEXT: addi sp, sp, 16 ; RV32IFD-NEXT: ret @@ -21,7 +20,6 @@ ; RV64IFD: # %bb.0: ; RV64IFD-NEXT: fmv.d.x ft0, a0 ; RV64IFD-NEXT: feq.d a0, ft0, ft0 -; RV64IFD-NEXT: and a0, a0, a0 ; RV64IFD-NEXT: seqz a0, a0 ; RV64IFD-NEXT: ret %2 = fcmp uno double %0, 0.000000e+00 @@ -36,7 +34,6 @@ ; RV32IFD-NEXT: sw a1, 12(sp) ; RV32IFD-NEXT: fld ft0, 8(sp) ; RV32IFD-NEXT: feq.d a0, ft0, ft0 -; RV32IFD-NEXT: and a0, a0, a0 ; RV32IFD-NEXT: addi sp, sp, 16 ; RV32IFD-NEXT: ret ; @@ -44,7 +41,6 @@ ; RV64IFD: # %bb.0: ; RV64IFD-NEXT: fmv.d.x ft0, a0 ; RV64IFD-NEXT: feq.d a0, ft0, ft0 -; RV64IFD-NEXT: and a0, a0, a0 ; RV64IFD-NEXT: ret %2 = fcmp ord double %0, 0.000000e+00 ret i1 %2 diff --git a/llvm/test/CodeGen/RISCV/float-isnan.ll b/llvm/test/CodeGen/RISCV/float-isnan.ll --- a/llvm/test/CodeGen/RISCV/float-isnan.ll +++ b/llvm/test/CodeGen/RISCV/float-isnan.ll @@ -9,7 +9,6 @@ ; RV32IF: # %bb.0: ; RV32IF-NEXT: fmv.w.x ft0, a0 ; RV32IF-NEXT: feq.s a0, ft0, ft0 -; RV32IF-NEXT: and a0, a0, a0 ; RV32IF-NEXT: seqz a0, a0 ; RV32IF-NEXT: ret ; @@ -17,7 +16,6 @@ ; RV64IF: # %bb.0: ; RV64IF-NEXT: fmv.w.x ft0, a0 ; RV64IF-NEXT: feq.s a0, ft0, ft0 -; RV64IF-NEXT: and a0, a0, a0 ; RV64IF-NEXT: seqz a0, a0 ; RV64IF-NEXT: ret %2 = fcmp uno float %0, 0.000000e+00 @@ -29,14 +27,12 @@ ; RV32IF: # %bb.0: ; RV32IF-NEXT: fmv.w.x ft0, a0 ; RV32IF-NEXT: feq.s a0, ft0, ft0 -; RV32IF-NEXT: and a0, a0, a0 ; RV32IF-NEXT: ret ; ; RV64IF-LABEL: float_not_nan: ; RV64IF: # %bb.0: ; RV64IF-NEXT: fmv.w.x ft0, a0 ; RV64IF-NEXT: feq.s a0, ft0, ft0 -; RV64IF-NEXT: and a0, a0, a0 ; RV64IF-NEXT: ret %2 = fcmp ord float %0, 0.000000e+00 ret i1 %2