Thanks to visit codestin.com
Credit goes to github.com

Skip to content

LoongArch: Set FMAXNUM and FMINNUM as Legal #139010

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
May 9, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions llvm/lib/Target/LoongArch/LoongArchFloat32InstrInfo.td
Original file line number Diff line number Diff line change
Expand Up @@ -172,7 +172,9 @@ def : PatFprFpr<fmul, FMUL_S, FPR32>;
def : PatFprFpr<fdiv, FDIV_S, FPR32>;
def : PatFprFpr<fcopysign, FCOPYSIGN_S, FPR32>;
def : PatFprFpr<fmaxnum_ieee, FMAX_S, FPR32>;
def : PatFprFpr<fmaxnum, FMAX_S, FPR32>;
def : PatFprFpr<fminnum_ieee, FMIN_S, FPR32>;
def : PatFprFpr<fminnum, FMIN_S, FPR32>;
def : PatFpr<fneg, FNEG_S, FPR32>;
def : PatFpr<fabs, FABS_S, FPR32>;
def : PatFpr<fsqrt, FSQRT_S, FPR32>;
Expand Down
2 changes: 2 additions & 0 deletions llvm/lib/Target/LoongArch/LoongArchFloat64InstrInfo.td
Original file line number Diff line number Diff line change
Expand Up @@ -140,7 +140,9 @@ def : PatFprFpr<fmul, FMUL_D, FPR64>;
def : PatFprFpr<fdiv, FDIV_D, FPR64>;
def : PatFprFpr<fcopysign, FCOPYSIGN_D, FPR64>;
def : PatFprFpr<fmaxnum_ieee, FMAX_D, FPR64>;
def : PatFprFpr<fmaxnum, FMAX_D, FPR64>;
def : PatFprFpr<fminnum_ieee, FMIN_D, FPR64>;
def : PatFprFpr<fminnum, FMIN_D, FPR64>;
def : PatFpr<fneg, FNEG_D, FPR64>;
def : PatFpr<fabs, FABS_D, FPR64>;
def : PatFpr<fsqrt, FSQRT_D, FPR64>;
Expand Down
4 changes: 4 additions & 0 deletions llvm/lib/Target/LoongArch/LoongArchISelLowering.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -176,7 +176,9 @@ LoongArchTargetLowering::LoongArchTargetLowering(const TargetMachine &TM,
setOperationAction(ISD::BR_CC, MVT::f32, Expand);
setOperationAction(ISD::FMA, MVT::f32, Legal);
setOperationAction(ISD::FMINNUM_IEEE, MVT::f32, Legal);
setOperationAction(ISD::FMINNUM, MVT::f32, Legal);
setOperationAction(ISD::FMAXNUM_IEEE, MVT::f32, Legal);
setOperationAction(ISD::FMAXNUM, MVT::f32, Legal);
setOperationAction(ISD::STRICT_FSETCCS, MVT::f32, Legal);
setOperationAction(ISD::STRICT_FSETCC, MVT::f32, Legal);
setOperationAction(ISD::IS_FPCLASS, MVT::f32, Legal);
Expand Down Expand Up @@ -215,7 +217,9 @@ LoongArchTargetLowering::LoongArchTargetLowering(const TargetMachine &TM,
setOperationAction(ISD::STRICT_FSETCC, MVT::f64, Legal);
setOperationAction(ISD::FMA, MVT::f64, Legal);
setOperationAction(ISD::FMINNUM_IEEE, MVT::f64, Legal);
setOperationAction(ISD::FMINNUM, MVT::f64, Legal);
setOperationAction(ISD::FMAXNUM_IEEE, MVT::f64, Legal);
setOperationAction(ISD::FMAXNUM, MVT::f64, Legal);
setOperationAction(ISD::IS_FPCLASS, MVT::f64, Legal);
setOperationAction(ISD::FSIN, MVT::f64, Expand);
setOperationAction(ISD::FCOS, MVT::f64, Expand);
Expand Down
24 changes: 0 additions & 24 deletions llvm/test/CodeGen/LoongArch/fp-max-min.ll
Original file line number Diff line number Diff line change
Expand Up @@ -12,29 +12,21 @@ declare double @llvm.minnum.f64(double, double)
define float @maxnum_float(float %x, float %y) {
; LA32F-LABEL: maxnum_float:
; LA32F: # %bb.0:
; LA32F-NEXT: fmax.s $fa1, $fa1, $fa1
; LA32F-NEXT: fmax.s $fa0, $fa0, $fa0
; LA32F-NEXT: fmax.s $fa0, $fa0, $fa1
; LA32F-NEXT: ret
;
; LA32D-LABEL: maxnum_float:
; LA32D: # %bb.0:
; LA32D-NEXT: fmax.s $fa1, $fa1, $fa1
; LA32D-NEXT: fmax.s $fa0, $fa0, $fa0
; LA32D-NEXT: fmax.s $fa0, $fa0, $fa1
; LA32D-NEXT: ret
;
; LA64F-LABEL: maxnum_float:
; LA64F: # %bb.0:
; LA64F-NEXT: fmax.s $fa1, $fa1, $fa1
; LA64F-NEXT: fmax.s $fa0, $fa0, $fa0
; LA64F-NEXT: fmax.s $fa0, $fa0, $fa1
; LA64F-NEXT: ret
;
; LA64D-LABEL: maxnum_float:
; LA64D: # %bb.0:
; LA64D-NEXT: fmax.s $fa1, $fa1, $fa1
; LA64D-NEXT: fmax.s $fa0, $fa0, $fa0
; LA64D-NEXT: fmax.s $fa0, $fa0, $fa1
; LA64D-NEXT: ret
%z = call float @llvm.maxnum.f32(float %x, float %y)
Expand All @@ -55,8 +47,6 @@ define double @maxnum_double(double %x, double %y) {
;
; LA32D-LABEL: maxnum_double:
; LA32D: # %bb.0:
; LA32D-NEXT: fmax.d $fa1, $fa1, $fa1
; LA32D-NEXT: fmax.d $fa0, $fa0, $fa0
; LA32D-NEXT: fmax.d $fa0, $fa0, $fa1
; LA32D-NEXT: ret
;
Expand All @@ -74,8 +64,6 @@ define double @maxnum_double(double %x, double %y) {
;
; LA64D-LABEL: maxnum_double:
; LA64D: # %bb.0:
; LA64D-NEXT: fmax.d $fa1, $fa1, $fa1
; LA64D-NEXT: fmax.d $fa0, $fa0, $fa0
; LA64D-NEXT: fmax.d $fa0, $fa0, $fa1
; LA64D-NEXT: ret
%z = call double @llvm.maxnum.f64(double %x, double %y)
Expand All @@ -85,29 +73,21 @@ define double @maxnum_double(double %x, double %y) {
define float @minnum_float(float %x, float %y) {
; LA32F-LABEL: minnum_float:
; LA32F: # %bb.0:
; LA32F-NEXT: fmax.s $fa1, $fa1, $fa1
; LA32F-NEXT: fmax.s $fa0, $fa0, $fa0
; LA32F-NEXT: fmin.s $fa0, $fa0, $fa1
; LA32F-NEXT: ret
;
; LA32D-LABEL: minnum_float:
; LA32D: # %bb.0:
; LA32D-NEXT: fmax.s $fa1, $fa1, $fa1
; LA32D-NEXT: fmax.s $fa0, $fa0, $fa0
; LA32D-NEXT: fmin.s $fa0, $fa0, $fa1
; LA32D-NEXT: ret
;
; LA64F-LABEL: minnum_float:
; LA64F: # %bb.0:
; LA64F-NEXT: fmax.s $fa1, $fa1, $fa1
; LA64F-NEXT: fmax.s $fa0, $fa0, $fa0
; LA64F-NEXT: fmin.s $fa0, $fa0, $fa1
; LA64F-NEXT: ret
;
; LA64D-LABEL: minnum_float:
; LA64D: # %bb.0:
; LA64D-NEXT: fmax.s $fa1, $fa1, $fa1
; LA64D-NEXT: fmax.s $fa0, $fa0, $fa0
; LA64D-NEXT: fmin.s $fa0, $fa0, $fa1
; LA64D-NEXT: ret
%z = call float @llvm.minnum.f32(float %x, float %y)
Expand All @@ -128,8 +108,6 @@ define double @minnum_double(double %x, double %y) {
;
; LA32D-LABEL: minnum_double:
; LA32D: # %bb.0:
; LA32D-NEXT: fmax.d $fa1, $fa1, $fa1
; LA32D-NEXT: fmax.d $fa0, $fa0, $fa0
; LA32D-NEXT: fmin.d $fa0, $fa0, $fa1
; LA32D-NEXT: ret
;
Expand All @@ -147,8 +125,6 @@ define double @minnum_double(double %x, double %y) {
;
; LA64D-LABEL: minnum_double:
; LA64D: # %bb.0:
; LA64D-NEXT: fmax.d $fa1, $fa1, $fa1
; LA64D-NEXT: fmax.d $fa0, $fa0, $fa0
; LA64D-NEXT: fmin.d $fa0, $fa0, $fa1
; LA64D-NEXT: ret
%z = call double @llvm.minnum.f64(double %x, double %y)
Expand Down
Loading