Skip to content

Commit b50b5af

Browse files
committed
[MIPS] match llvm.{min,max}num with {min,max}.fmt for R6
- The behavior is similar to UCOMISD on x86, which is also used to compare two fp values, specifically on handling of NaNs. - Update related tests regarding this change.
1 parent 090c92e commit b50b5af

File tree

3 files changed

+326
-186
lines changed

3 files changed

+326
-186
lines changed

llvm/lib/Target/Mips/Mips32r6InstrInfo.td

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1117,6 +1117,22 @@ def : MipsPat<(select i32:$cond, immz, i32:$f),
11171117
ISA_MIPS32R6;
11181118
}
11191119

1120+
// llvm.fmin/fmax operations.
1121+
let AdditionalPredicates = [NotInMicroMips] in {
1122+
def : MipsPat<(fmaxnum f32:$lhs, f32:$rhs),
1123+
(MAX_S f32:$lhs, f32:$rhs)>,
1124+
ISA_MIPS32R6;
1125+
def : MipsPat<(fmaxnum f64:$lhs, f64:$rhs),
1126+
(MAX_D f64:$lhs, f64:$rhs)>,
1127+
ISA_MIPS32R6;
1128+
def : MipsPat<(fminnum f32:$lhs, f32:$rhs),
1129+
(MIN_S f32:$lhs, f32:$rhs)>,
1130+
ISA_MIPS32R6;
1131+
def : MipsPat<(fminnum f64:$lhs, f64:$rhs),
1132+
(MIN_D f64:$lhs, f64:$rhs)>,
1133+
ISA_MIPS32R6;
1134+
}
1135+
11201136
// Pseudo instructions
11211137
let isCall = 1, isTerminator = 1, isReturn = 1, isBarrier = 1, hasDelaySlot = 1,
11221138
hasExtraSrcRegAllocReq = 1, isCTI = 1, Defs = [AT], hasPostISelHook = 1 in {

llvm/lib/Target/Mips/MipsISelLowering.cpp

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -358,6 +358,15 @@ MipsTargetLowering::MipsTargetLowering(const MipsTargetMachine &TM,
358358
setOperationAction(ISD::FCOPYSIGN, MVT::f64, Custom);
359359
setOperationAction(ISD::FP_TO_SINT, MVT::i32, Custom);
360360

361+
// Lower fmin and fmax operations for MIPS R6.
362+
// Instructions are defined but never used.
363+
if (Subtarget.hasMips32r6()) {
364+
setOperationAction(ISD::FMINNUM, MVT::f32, Legal);
365+
setOperationAction(ISD::FMINNUM, MVT::f64, Legal);
366+
setOperationAction(ISD::FMAXNUM, MVT::f32, Legal);
367+
setOperationAction(ISD::FMAXNUM, MVT::f64, Legal);
368+
}
369+
361370
if (Subtarget.isGP64bit()) {
362371
setOperationAction(ISD::GlobalAddress, MVT::i64, Custom);
363372
setOperationAction(ISD::BlockAddress, MVT::i64, Custom);

0 commit comments

Comments
 (0)