Index: llvm/include/llvm/CodeGen/GlobalISel/CombinerHelper.h =================================================================== --- llvm/include/llvm/CodeGen/GlobalISel/CombinerHelper.h +++ llvm/include/llvm/CodeGen/GlobalISel/CombinerHelper.h @@ -21,6 +21,7 @@ #include "llvm/ADT/SmallVector.h" #include "llvm/CodeGen/Register.h" #include "llvm/Support/LowLevelTypeImpl.h" +#include "llvm/IR/InstrTypes.h" #include namespace llvm { @@ -740,6 +741,10 @@ /// Transform G_ADD(G_SUB(y, x), x) to y. bool matchAddSubSameReg(MachineInstr &MI, Register &Src); + /// \returns true if it is possible to simplify a select instruction \p MI + /// to a min/max instruction of some sort. + bool matchSimplifySelectToMinMax(MachineInstr &MI, BuildFnTy &MatchInfo); + private: /// Given a non-indexed load or store instruction \p MI, find an offset that /// can be usefully and legally folded into it as a post-indexing operation. @@ -785,6 +790,49 @@ /// a re-association of its operands would break an existing legal addressing /// mode that the address computation currently represents. bool reassociationCanBreakAddressingModePattern(MachineInstr &PtrAdd); + + /// Behavior when a floating point min/max is given one NaN and one + /// non-NaN as input. + enum class SelectPatternNaNBehaviour { + NOT_APPLICABLE = 0, /// NaN behavior not applicable. + RETURNS_NAN, /// Given one NaN input, returns the NaN. + RETURNS_OTHER, /// Given one NaN input, returns the non-NaN. + RETURNS_ANY /// Given one NaN input, can return either (or both operands are + /// known non-NaN.) + }; + + /// \returns which of \p LHS and \p RHS would be the result of a non-equality + /// floating point comparison where one of \p LHS and \p RHS may be NaN. + /// + /// If both \p LHS and \p RHS may be NaN, returns + /// SelectPatternNaNBehaviour::NOT_APPLICABLE. + SelectPatternNaNBehaviour + computeRetValAgainstNaN(Register LHS, Register RHS, + bool IsOrderedComparison) const; + + /// Determines the floating point min/max opcode which should be used for + /// a G_SELECT fed by a G_FCMP with predicate \p Pred. + /// + /// \returns 0 if this G_SELECT should not be combined to a floating point + /// min or max. If it should be combined, returns one of + /// + /// * G_FMAXNUM + /// * G_FMAXIMUM + /// * G_FMINNUM + /// * G_FMINIMUM + /// + /// Helper function for matchFPSelectToMinMax. + unsigned getFPMinMaxOpcForSelect(CmpInst::Predicate Pred, LLT DstTy, + SelectPatternNaNBehaviour VsNaNRetVal) const; + + /// Handle floating point cases for matchSimplifySelectToMinMax. + /// + /// E.g. + /// + /// select (fcmp uge x, 1.0) x, 1.0 -> fmax x, 1.0 + /// select (fcmp uge x, 1.0) 1.0, x -> fminnm x, 1.0 + bool matchFPSelectToMinMax(Register Dst, Register Cond, Register TrueVal, + Register FalseVal, BuildFnTy &MatchInfo); }; } // namespace llvm Index: llvm/include/llvm/Target/GlobalISel/Combine.td =================================================================== --- llvm/include/llvm/Target/GlobalISel/Combine.td +++ llvm/include/llvm/Target/GlobalISel/Combine.td @@ -906,6 +906,12 @@ (apply [{ return Helper.replaceSingleDefInstWithReg(*${root}, ${matchinfo}); }])>; +def select_to_minmax: GICombineRule< + (defs root:$root, build_fn_matchinfo:$info), + (match (wip_match_opcode G_SELECT):$root, + [{ return Helper.matchSimplifySelectToMinMax(*${root}, ${info}); }]), + (apply [{ Helper.applyBuildFn(*${root}, ${info}); }])>; + // FIXME: These should use the custom predicate feature once it lands. def undef_combines : GICombineGroup<[undef_to_fp_zero, undef_to_int_zero, undef_to_negative_one, Index: llvm/lib/CodeGen/GlobalISel/CombinerHelper.cpp =================================================================== --- llvm/lib/CodeGen/GlobalISel/CombinerHelper.cpp +++ llvm/lib/CodeGen/GlobalISel/CombinerHelper.cpp @@ -5669,6 +5669,138 @@ return CheckFold(LHS, RHS) || CheckFold(RHS, LHS); } +unsigned CombinerHelper::getFPMinMaxOpcForSelect( + CmpInst::Predicate Pred, LLT DstTy, + SelectPatternNaNBehaviour VsNaNRetVal) const { + assert(VsNaNRetVal != SelectPatternNaNBehaviour::NOT_APPLICABLE && + "Expected a NaN behaviour?"); + // Choose an opcode based off of legality or the behaviour when one of the + // LHS/RHS may be NaN. + switch (Pred) { + default: + return 0; + case CmpInst::FCMP_UGT: + case CmpInst::FCMP_UGE: + case CmpInst::FCMP_OGT: + case CmpInst::FCMP_OGE: + if (VsNaNRetVal == SelectPatternNaNBehaviour::RETURNS_OTHER) + return TargetOpcode::G_FMAXNUM; + if (VsNaNRetVal == SelectPatternNaNBehaviour::RETURNS_NAN) + return TargetOpcode::G_FMAXIMUM; + if (isLegal({TargetOpcode::G_FMAXNUM, {DstTy}})) + return TargetOpcode::G_FMAXNUM; + if (isLegal({TargetOpcode::G_FMAXIMUM, {DstTy}})) + return TargetOpcode::G_FMAXIMUM; + return 0; + case CmpInst::FCMP_ULT: + case CmpInst::FCMP_ULE: + case CmpInst::FCMP_OLT: + case CmpInst::FCMP_OLE: + if (VsNaNRetVal == SelectPatternNaNBehaviour::RETURNS_OTHER) + return TargetOpcode::G_FMINNUM; + if (VsNaNRetVal == SelectPatternNaNBehaviour::RETURNS_NAN) + return TargetOpcode::G_FMINIMUM; + if (isLegal({TargetOpcode::G_FMINNUM, {DstTy}})) + return TargetOpcode::G_FMINNUM; + if (!isLegal({TargetOpcode::G_FMINIMUM, {DstTy}})) + return 0; + return TargetOpcode::G_FMINIMUM; + } +} + +CombinerHelper::SelectPatternNaNBehaviour +CombinerHelper::computeRetValAgainstNaN(Register LHS, Register RHS, + bool IsOrderedComparison) const { + bool LHSSafe = isKnownNeverNaN(LHS, MRI); + bool RHSSafe = isKnownNeverNaN(RHS, MRI); + // Completely unsafe. + if (!LHSSafe && !RHSSafe) + return SelectPatternNaNBehaviour::NOT_APPLICABLE; + if (LHSSafe && RHSSafe) + return SelectPatternNaNBehaviour::RETURNS_ANY; + // An ordered comparison will return false when given a NaN, so it + // returns the RHS. + if (IsOrderedComparison) + return LHSSafe ? SelectPatternNaNBehaviour::RETURNS_NAN + : SelectPatternNaNBehaviour::RETURNS_OTHER; + // An unordered comparison will return true when given a NaN, so it + // returns the LHS. + return LHSSafe ? SelectPatternNaNBehaviour::RETURNS_OTHER + : SelectPatternNaNBehaviour::RETURNS_NAN; +} + +bool CombinerHelper::matchFPSelectToMinMax(Register Dst, Register Cond, + Register TrueVal, Register FalseVal, + BuildFnTy &MatchInfo) { + // Match: select (fcmp cond x, y) x, y + // select (fcmp cond x, y) y, x + // And turn it into fminnum/fmaxnum or fmin/fmax based off of the condition. + LLT DstTy = MRI.getType(Dst); + // Bail out early on pointers, since we'll never want to fold to a min/max. + // TODO: Handle vectors. + if (DstTy.isPointer() || DstTy.isVector()) + return false; + // Match a floating point compare with a less-than/greater-than predicate. + // TODO: Allow multiple users of the compare if they are all selects. + CmpInst::Predicate Pred; + Register CmpLHS, CmpRHS; + if (!mi_match(Cond, MRI, + m_OneNonDBGUse( + m_GFCmp(m_Pred(Pred), m_Reg(CmpLHS), m_Reg(CmpRHS)))) || + CmpInst::isEquality(Pred)) + return false; + SelectPatternNaNBehaviour ResWithKnownNaNInfo = + computeRetValAgainstNaN(CmpLHS, CmpRHS, CmpInst::isOrdered(Pred)); + if (ResWithKnownNaNInfo == SelectPatternNaNBehaviour::NOT_APPLICABLE) + return false; + if (TrueVal == CmpRHS && FalseVal == CmpLHS) { + std::swap(CmpLHS, CmpRHS); + Pred = CmpInst::getSwappedPredicate(Pred); + if (ResWithKnownNaNInfo == SelectPatternNaNBehaviour::RETURNS_NAN) + ResWithKnownNaNInfo = SelectPatternNaNBehaviour::RETURNS_OTHER; + else if (ResWithKnownNaNInfo == SelectPatternNaNBehaviour::RETURNS_OTHER) + ResWithKnownNaNInfo = SelectPatternNaNBehaviour::RETURNS_NAN; + } + if (TrueVal != CmpLHS || FalseVal != CmpRHS) + return false; + // Decide what type of max/min this should be based off of the predicate. + unsigned Opc = getFPMinMaxOpcForSelect(Pred, DstTy, ResWithKnownNaNInfo); + if (!Opc || !isLegal({Opc, {DstTy}})) + return false; + // Comparisons between signed zero and zero may have different results... + // unless we have fmaximum/fminimum. In that case, we know -0 < 0. + if (Opc != TargetOpcode::G_FMAXIMUM && Opc != TargetOpcode::G_FMINIMUM) { + // We don't know if a comparison between two 0s will give us a consistent + // result. Be conservative and only proceed if at least one side is + // non-zero. + auto KnownNonZeroSide = getFConstantVRegValWithLookThrough(CmpLHS, MRI); + if (!KnownNonZeroSide || !KnownNonZeroSide->Value.isNonZero()) { + KnownNonZeroSide = getFConstantVRegValWithLookThrough(CmpRHS, MRI); + if (!KnownNonZeroSide || !KnownNonZeroSide->Value.isNonZero()) + return false; + } + } + MatchInfo = [=](MachineIRBuilder &B) { + B.buildInstr(Opc, {Dst}, {CmpLHS, CmpRHS}); + }; + return true; +} + +bool CombinerHelper::matchSimplifySelectToMinMax(MachineInstr &MI, + BuildFnTy &MatchInfo) { + // TODO: Handle integer cases. + assert(MI.getOpcode() == TargetOpcode::G_SELECT); + // Condition may be fed by a truncated compare. + Register Cond = MI.getOperand(1).getReg(); + Register MaybeTrunc; + if (mi_match(Cond, MRI, m_OneNonDBGUse(m_GTrunc(m_Reg(MaybeTrunc))))) + Cond = MaybeTrunc; + Register Dst = MI.getOperand(0).getReg(); + Register TrueVal = MI.getOperand(2).getReg(); + Register FalseVal = MI.getOperand(3).getReg(); + return matchFPSelectToMinMax(Dst, Cond, TrueVal, FalseVal, MatchInfo); +} + bool CombinerHelper::tryCombine(MachineInstr &MI) { if (tryCombineCopy(MI)) return true; Index: llvm/lib/Target/AArch64/AArch64Combine.td =================================================================== --- llvm/lib/Target/AArch64/AArch64Combine.td +++ llvm/lib/Target/AArch64/AArch64Combine.td @@ -228,6 +228,7 @@ select_combines, fold_merge_to_zext, constant_fold, identity_combines, ptr_add_immed_chain, overlapping_and, - split_store_zero_128, undef_combines]> { + split_store_zero_128, undef_combines, + select_to_minmax]> { let DisableRuleOption = "aarch64postlegalizercombiner-disable-rule"; } Index: llvm/test/CodeGen/AArch64/GlobalISel/combine-select-to-fminnum-fmaxnum.mir =================================================================== --- /dev/null +++ llvm/test/CodeGen/AArch64/GlobalISel/combine-select-to-fminnum-fmaxnum.mir @@ -0,0 +1,1452 @@ +# NOTE: Assertions have been autogenerated by utils/update_mir_test_checks.py +# RUN: llc -mtriple aarch64 -run-pass=aarch64-postlegalizer-combiner --aarch64postlegalizercombinerhelper-only-enable-rule="select_to_minmax" -verify-machineinstrs %s -o - | FileCheck %s + +################################################################################ +########################## G_FMAXNUM Positive Cases ############################ +################################################################################ + +#################### LHS and RHS both known to not be NaN. ##################### +... +--- +name: ugt_fmaxnum_lhs_rhs_safe +alignment: 4 +legalized: true +tracksRegLiveness: true +body: | + bb.1.entry: + liveins: $s0, $s1 + ; CHECK-LABEL: name: ugt_fmaxnum_lhs_rhs_safe + ; CHECK: liveins: $s0, $s1 + ; CHECK-NEXT: {{ $}} + ; CHECK-NEXT: %lhs:_(s32) = nnan COPY $s0 + ; CHECK-NEXT: %rhs:_(s32) = G_FCONSTANT float 1.000000e+00 + ; CHECK-NEXT: %select:_(s32) = G_FMAXNUM %lhs, %rhs + ; CHECK-NEXT: $s0 = COPY %select(s32) + ; CHECK-NEXT: RET_ReallyLR implicit $s0 + %lhs:_(s32) = nnan COPY $s0 + %rhs:_(s32) = G_FCONSTANT float 1.0 + %fcmp:_(s32) = G_FCMP floatpred(ugt), %lhs(s32), %rhs + %select:_(s32) = G_SELECT %fcmp, %lhs, %rhs + $s0 = COPY %select + RET_ReallyLR implicit $s0 +... +--- +name: uge_fmaxnum_lhs_rhs_safe +alignment: 4 +legalized: true +tracksRegLiveness: true +body: | + bb.1.entry: + liveins: $s0, $s1 + ; CHECK-LABEL: name: uge_fmaxnum_lhs_rhs_safe + ; CHECK: liveins: $s0, $s1 + ; CHECK-NEXT: {{ $}} + ; CHECK-NEXT: %lhs:_(s32) = nnan COPY $s0 + ; CHECK-NEXT: %rhs:_(s32) = G_FCONSTANT float 1.000000e+00 + ; CHECK-NEXT: %select:_(s32) = G_FMAXNUM %lhs, %rhs + ; CHECK-NEXT: $s0 = COPY %select(s32) + ; CHECK-NEXT: RET_ReallyLR implicit $s0 + %lhs:_(s32) = nnan COPY $s0 + %rhs:_(s32) = G_FCONSTANT float 1.0 + %fcmp:_(s32) = G_FCMP floatpred(uge), %lhs(s32), %rhs + %select:_(s32) = G_SELECT %fcmp, %lhs, %rhs + $s0 = COPY %select + RET_ReallyLR implicit $s0 +... +--- +name: ogt_fmaxnum_lhs_rhs_safe +alignment: 4 +legalized: true +tracksRegLiveness: true +body: | + bb.1.entry: + liveins: $s0, $s1 + ; CHECK-LABEL: name: ogt_fmaxnum_lhs_rhs_safe + ; CHECK: liveins: $s0, $s1 + ; CHECK-NEXT: {{ $}} + ; CHECK-NEXT: %lhs:_(s32) = nnan COPY $s0 + ; CHECK-NEXT: %rhs:_(s32) = G_FCONSTANT float 1.000000e+00 + ; CHECK-NEXT: %select:_(s32) = G_FMAXNUM %lhs, %rhs + ; CHECK-NEXT: $s0 = COPY %select(s32) + ; CHECK-NEXT: RET_ReallyLR implicit $s0 + %lhs:_(s32) = nnan COPY $s0 + %rhs:_(s32) = G_FCONSTANT float 1.0 + %fcmp:_(s32) = G_FCMP floatpred(ogt), %lhs(s32), %rhs + %select:_(s32) = G_SELECT %fcmp, %lhs, %rhs + $s0 = COPY %select + RET_ReallyLR implicit $s0 +... +--- +name: oge_fmaxnum_lhs_rhs_safe +alignment: 4 +legalized: true +tracksRegLiveness: true +body: | + bb.1.entry: + liveins: $s0, $s1 + ; CHECK-LABEL: name: oge_fmaxnum_lhs_rhs_safe + ; CHECK: liveins: $s0, $s1 + ; CHECK-NEXT: {{ $}} + ; CHECK-NEXT: %lhs:_(s32) = nnan COPY $s0 + ; CHECK-NEXT: %rhs:_(s32) = G_FCONSTANT float 1.000000e+00 + ; CHECK-NEXT: %select:_(s32) = G_FMAXNUM %lhs, %rhs + ; CHECK-NEXT: $s0 = COPY %select(s32) + ; CHECK-NEXT: RET_ReallyLR implicit $s0 + %lhs:_(s32) = nnan COPY $s0 + %rhs:_(s32) = G_FCONSTANT float 1.0 + %fcmp:_(s32) = G_FCMP floatpred(oge), %lhs(s32), %rhs + %select:_(s32) = G_SELECT %fcmp, %lhs, %rhs + $s0 = COPY %select + RET_ReallyLR implicit $s0 + +#################### Unordered preds, LHS known non-NaN. ####################### +... +--- +name: ugt_fmaxnum_lhs_safe +alignment: 4 +legalized: true +tracksRegLiveness: true +body: | + bb.1.entry: + liveins: $s0, $s1 + ; CHECK-LABEL: name: ugt_fmaxnum_lhs_safe + ; CHECK: liveins: $s0, $s1 + ; CHECK-NEXT: {{ $}} + ; CHECK-NEXT: %lhs:_(s32) = G_FCONSTANT float 1.000000e+00 + ; CHECK-NEXT: %rhs:_(s32) = COPY $s1 + ; CHECK-NEXT: %select:_(s32) = G_FMAXNUM %lhs, %rhs + ; CHECK-NEXT: $s0 = COPY %select(s32) + ; CHECK-NEXT: RET_ReallyLR implicit $s0 + %lhs:_(s32) = G_FCONSTANT float 1.000000e+00 + %rhs:_(s32) = COPY $s1 + %fcmp:_(s32) = G_FCMP floatpred(ugt), %lhs(s32), %rhs + %select:_(s32) = G_SELECT %fcmp, %lhs, %rhs + $s0 = COPY %select + RET_ReallyLR implicit $s0 +... +--- +name: uge_fmaxnum_lhs_safe +alignment: 4 +legalized: true +tracksRegLiveness: true +body: | + bb.1.entry: + liveins: $s0, $s1 + ; CHECK-LABEL: name: uge_fmaxnum_lhs_safe + ; CHECK: liveins: $s0, $s1 + ; CHECK-NEXT: {{ $}} + ; CHECK-NEXT: %lhs:_(s32) = G_FCONSTANT float 1.000000e+00 + ; CHECK-NEXT: %rhs:_(s32) = COPY $s1 + ; CHECK-NEXT: %select:_(s32) = G_FMAXNUM %lhs, %rhs + ; CHECK-NEXT: $s0 = COPY %select(s32) + ; CHECK-NEXT: RET_ReallyLR implicit $s0 + %lhs:_(s32) = G_FCONSTANT float 1.000000e+00 + %rhs:_(s32) = COPY $s1 + %fcmp:_(s32) = G_FCMP floatpred(uge), %lhs(s32), %rhs + %select:_(s32) = G_SELECT %fcmp, %lhs, %rhs + $s0 = COPY %select + RET_ReallyLR implicit $s0 + +##################### Ordered preds, RHS known non-NaN. ######################## +... +--- +name: ogt_fmaxnum_rhs_safe +alignment: 4 +legalized: true +tracksRegLiveness: true +body: | + bb.1.entry: + liveins: $s0, $s1 + ; CHECK-LABEL: name: ogt_fmaxnum_rhs_safe + ; CHECK: liveins: $s0, $s1 + ; CHECK-NEXT: {{ $}} + ; CHECK-NEXT: %lhs:_(s32) = COPY $s1 + ; CHECK-NEXT: %rhs:_(s32) = G_FCONSTANT float 1.000000e+00 + ; CHECK-NEXT: %select:_(s32) = G_FMAXNUM %lhs, %rhs + ; CHECK-NEXT: $s0 = COPY %select(s32) + ; CHECK-NEXT: RET_ReallyLR implicit $s0 + %lhs:_(s32) = COPY $s1 + %rhs:_(s32) = G_FCONSTANT float 1.000000e+00 + %fcmp:_(s32) = G_FCMP floatpred(ogt), %lhs(s32), %rhs + %select:_(s32) = G_SELECT %fcmp, %lhs, %rhs + $s0 = COPY %select + RET_ReallyLR implicit $s0 +... +--- +name: oge_fmaxnum_rhs_safe +alignment: 4 +legalized: true +tracksRegLiveness: true +body: | + bb.1.entry: + liveins: $s0, $s1 + ; CHECK-LABEL: name: oge_fmaxnum_rhs_safe + ; CHECK: liveins: $s0, $s1 + ; CHECK-NEXT: {{ $}} + ; CHECK-NEXT: %lhs:_(s32) = COPY $s1 + ; CHECK-NEXT: %rhs:_(s32) = G_FCONSTANT float 1.000000e+00 + ; CHECK-NEXT: %select:_(s32) = G_FMAXNUM %lhs, %rhs + ; CHECK-NEXT: $s0 = COPY %select(s32) + ; CHECK-NEXT: RET_ReallyLR implicit $s0 + %lhs:_(s32) = COPY $s1 + %rhs:_(s32) = G_FCONSTANT float 1.000000e+00 + %fcmp:_(s32) = G_FCMP floatpred(oge), %lhs(s32), %rhs + %select:_(s32) = G_SELECT %fcmp, %lhs, %rhs + $s0 = COPY %select + RET_ReallyLR implicit $s0 + +############################## Swapped operands ################################ +... +--- +name: ult_fmaxnum_lhs_safe +alignment: 4 +legalized: true +tracksRegLiveness: true +body: | + bb.1.entry: + liveins: $s0, $s1 + ; CHECK-LABEL: name: ult_fmaxnum_lhs_safe + ; CHECK: liveins: $s0, $s1 + ; CHECK-NEXT: {{ $}} + ; CHECK-NEXT: %lhs:_(s32) = G_FCONSTANT float 1.000000e+00 + ; CHECK-NEXT: %rhs:_(s32) = COPY $s1 + ; CHECK-NEXT: %select:_(s32) = G_FMAXNUM %lhs, %rhs + ; CHECK-NEXT: $s0 = COPY %select(s32) + ; CHECK-NEXT: RET_ReallyLR implicit $s0 + %lhs:_(s32) = G_FCONSTANT float 1.000000e+00 + %rhs:_(s32) = COPY $s1 + %fcmp:_(s32) = G_FCMP floatpred(ult), %rhs(s32), %lhs + %select:_(s32) = G_SELECT %fcmp, %lhs, %rhs + $s0 = COPY %select + RET_ReallyLR implicit $s0 +... +--- +name: ule_fmaxnum_lhs_safe +alignment: 4 +legalized: true +tracksRegLiveness: true +body: | + bb.1.entry: + liveins: $s0, $s1 + ; CHECK-LABEL: name: ule_fmaxnum_lhs_safe + ; CHECK: liveins: $s0, $s1 + ; CHECK-NEXT: {{ $}} + ; CHECK-NEXT: %lhs:_(s32) = G_FCONSTANT float 1.000000e+00 + ; CHECK-NEXT: %rhs:_(s32) = COPY $s1 + ; CHECK-NEXT: %select:_(s32) = G_FMAXNUM %lhs, %rhs + ; CHECK-NEXT: $s0 = COPY %select(s32) + ; CHECK-NEXT: RET_ReallyLR implicit $s0 + %lhs:_(s32) = G_FCONSTANT float 1.000000e+00 + %rhs:_(s32) = COPY $s1 + %fcmp:_(s32) = G_FCMP floatpred(ule), %rhs(s32), %lhs + %select:_(s32) = G_SELECT %fcmp, %lhs, %rhs + $s0 = COPY %select + RET_ReallyLR implicit $s0 +... +--- +name: ole_fmaxnum_rhs_safe +alignment: 4 +legalized: true +tracksRegLiveness: true +body: | + bb.1.entry: + liveins: $s0, $s1 + ; CHECK-LABEL: name: ole_fmaxnum_rhs_safe + ; CHECK: liveins: $s0, $s1 + ; CHECK-NEXT: {{ $}} + ; CHECK-NEXT: %lhs:_(s32) = COPY $s1 + ; CHECK-NEXT: %rhs:_(s32) = G_FCONSTANT float 1.000000e+00 + ; CHECK-NEXT: %select:_(s32) = G_FMAXNUM %lhs, %rhs + ; CHECK-NEXT: $s0 = COPY %select(s32) + ; CHECK-NEXT: RET_ReallyLR implicit $s0 + %lhs:_(s32) = COPY $s1 + %rhs:_(s32) = G_FCONSTANT float 1.000000e+00 + %fcmp:_(s32) = G_FCMP floatpred(ole), %rhs(s32), %lhs + %select:_(s32) = G_SELECT %fcmp, %lhs, %rhs + $s0 = COPY %select + RET_ReallyLR implicit $s0 +... +--- +name: olt_fmaxnum_rhs_safe +alignment: 4 +legalized: true +tracksRegLiveness: true +body: | + bb.1.entry: + liveins: $s0, $s1 + ; CHECK-LABEL: name: olt_fmaxnum_rhs_safe + ; CHECK: liveins: $s0, $s1 + ; CHECK-NEXT: {{ $}} + ; CHECK-NEXT: %lhs:_(s32) = COPY $s1 + ; CHECK-NEXT: %rhs:_(s32) = G_FCONSTANT float 1.000000e+00 + ; CHECK-NEXT: %select:_(s32) = G_FMAXNUM %lhs, %rhs + ; CHECK-NEXT: $s0 = COPY %select(s32) + ; CHECK-NEXT: RET_ReallyLR implicit $s0 + %lhs:_(s32) = COPY $s1 + %rhs:_(s32) = G_FCONSTANT float 1.000000e+00 + %fcmp:_(s32) = G_FCMP floatpred(olt), %rhs(s32), %lhs + %select:_(s32) = G_SELECT %fcmp, %lhs, %rhs + $s0 = COPY %select + RET_ReallyLR implicit $s0 + +################################################################################ +########################## G_FMAXIMUM Positive Cases ############################ +################################################################################ + +##################### Ordered preds, LHS known non-NaN. ######################## +... +--- +name: ogt_fmaximum_rhs_safe +alignment: 4 +legalized: true +tracksRegLiveness: true +body: | + bb.1.entry: + liveins: $s0, $s1 + ; CHECK-LABEL: name: ogt_fmaximum_rhs_safe + ; CHECK: liveins: $s0, $s1 + ; CHECK-NEXT: {{ $}} + ; CHECK-NEXT: %lhs:_(s32) = G_FCONSTANT float 1.000000e+00 + ; CHECK-NEXT: %rhs:_(s32) = COPY $s0 + ; CHECK-NEXT: %select:_(s32) = G_FMAXIMUM %lhs, %rhs + ; CHECK-NEXT: $s0 = COPY %select(s32) + ; CHECK-NEXT: RET_ReallyLR implicit $s0 + %lhs:_(s32) = G_FCONSTANT float 1.0 + %rhs:_(s32) = COPY $s0 + %fcmp:_(s32) = G_FCMP floatpred(ogt), %lhs(s32), %rhs + %select:_(s32) = G_SELECT %fcmp, %lhs, %rhs + $s0 = COPY %select + RET_ReallyLR implicit $s0 +... +--- +name: oge_fmaximum_rhs_safe +alignment: 4 +legalized: true +tracksRegLiveness: true +body: | + bb.1.entry: + liveins: $s0, $s1 + ; CHECK-LABEL: name: oge_fmaximum_rhs_safe + ; CHECK: liveins: $s0, $s1 + ; CHECK-NEXT: {{ $}} + ; CHECK-NEXT: %lhs:_(s32) = G_FCONSTANT float 1.000000e+00 + ; CHECK-NEXT: %rhs:_(s32) = COPY $s0 + ; CHECK-NEXT: %select:_(s32) = G_FMAXIMUM %lhs, %rhs + ; CHECK-NEXT: $s0 = COPY %select(s32) + ; CHECK-NEXT: RET_ReallyLR implicit $s0 + %lhs:_(s32) = G_FCONSTANT float 1.0 + %rhs:_(s32) = COPY $s0 + %fcmp:_(s32) = G_FCMP floatpred(oge), %lhs(s32), %rhs + %select:_(s32) = G_SELECT %fcmp, %lhs, %rhs + $s0 = COPY %select + RET_ReallyLR implicit $s0 + +#################### Unordered preds, RHS known non-NaN. ####################### +... +--- +name: ugt_fmaximum_rhs_safe +alignment: 4 +legalized: true +tracksRegLiveness: true +body: | + bb.1.entry: + liveins: $s0, $s1 + ; CHECK-LABEL: name: ugt_fmaximum_rhs_safe + ; CHECK: liveins: $s0, $s1 + ; CHECK-NEXT: {{ $}} + ; CHECK-NEXT: %lhs:_(s32) = COPY $s0 + ; CHECK-NEXT: %rhs:_(s32) = G_FCONSTANT float 1.000000e+00 + ; CHECK-NEXT: %select:_(s32) = G_FMAXIMUM %lhs, %rhs + ; CHECK-NEXT: $s0 = COPY %select(s32) + ; CHECK-NEXT: RET_ReallyLR implicit $s0 + %lhs:_(s32) = COPY $s0 + %rhs:_(s32) = G_FCONSTANT float 1.0 + %fcmp:_(s32) = G_FCMP floatpred(ugt), %lhs(s32), %rhs + %select:_(s32) = G_SELECT %fcmp, %lhs, %rhs + $s0 = COPY %select + RET_ReallyLR implicit $s0 +... +--- +name: uge_fmaximum_rhs_safe +alignment: 4 +legalized: true +tracksRegLiveness: true +body: | + bb.1.entry: + liveins: $s0, $s1 + ; CHECK-LABEL: name: uge_fmaximum_rhs_safe + ; CHECK: liveins: $s0, $s1 + ; CHECK-NEXT: {{ $}} + ; CHECK-NEXT: %lhs:_(s32) = COPY $s0 + ; CHECK-NEXT: %rhs:_(s32) = G_FCONSTANT float 1.000000e+00 + ; CHECK-NEXT: %select:_(s32) = G_FMAXIMUM %lhs, %rhs + ; CHECK-NEXT: $s0 = COPY %select(s32) + ; CHECK-NEXT: RET_ReallyLR implicit $s0 + %lhs:_(s32) = COPY $s0 + %rhs:_(s32) = G_FCONSTANT float 1.0 + %fcmp:_(s32) = G_FCMP floatpred(uge), %lhs(s32), %rhs + %select:_(s32) = G_SELECT %fcmp, %lhs, %rhs + $s0 = COPY %select + RET_ReallyLR implicit $s0 + +############################## Swapped operands ################################ +... +--- +name: ole_fmaximum_lhs_safe +alignment: 4 +legalized: true +tracksRegLiveness: true +body: | + bb.1.entry: + liveins: $s0, $s1 + ; CHECK-LABEL: name: ole_fmaximum_lhs_safe + ; CHECK: liveins: $s0, $s1 + ; CHECK-NEXT: {{ $}} + ; CHECK-NEXT: %lhs:_(s32) = G_FCONSTANT float 1.000000e+00 + ; CHECK-NEXT: %rhs:_(s32) = COPY $s1 + ; CHECK-NEXT: %select:_(s32) = G_FMAXIMUM %lhs, %rhs + ; CHECK-NEXT: $s0 = COPY %select(s32) + ; CHECK-NEXT: RET_ReallyLR implicit $s0 + %lhs:_(s32) = G_FCONSTANT float 1.000000e+00 + %rhs:_(s32) = COPY $s1 + %fcmp:_(s32) = G_FCMP floatpred(ole), %rhs(s32), %lhs + %select:_(s32) = G_SELECT %fcmp, %lhs, %rhs + $s0 = COPY %select + RET_ReallyLR implicit $s0 + +... +--- +name: olt_fmaximum_lhs_safe +alignment: 4 +legalized: true +tracksRegLiveness: true +body: | + bb.1.entry: + liveins: $s0, $s1 + ; CHECK-LABEL: name: olt_fmaximum_lhs_safe + ; CHECK: liveins: $s0, $s1 + ; CHECK-NEXT: {{ $}} + ; CHECK-NEXT: %lhs:_(s32) = G_FCONSTANT float 1.000000e+00 + ; CHECK-NEXT: %rhs:_(s32) = COPY $s1 + ; CHECK-NEXT: %select:_(s32) = G_FMAXIMUM %lhs, %rhs + ; CHECK-NEXT: $s0 = COPY %select(s32) + ; CHECK-NEXT: RET_ReallyLR implicit $s0 + %lhs:_(s32) = G_FCONSTANT float 1.000000e+00 + %rhs:_(s32) = COPY $s1 + %fcmp:_(s32) = G_FCMP floatpred(olt), %rhs(s32), %lhs + %select:_(s32) = G_SELECT %fcmp, %lhs, %rhs + $s0 = COPY %select + RET_ReallyLR implicit $s0 +... +--- +name: ult_fmaximum_rhs_safe +alignment: 4 +legalized: true +tracksRegLiveness: true +body: | + bb.1.entry: + liveins: $s0, $s1 + ; CHECK-LABEL: name: ult_fmaximum_rhs_safe + ; CHECK: liveins: $s0, $s1 + ; CHECK-NEXT: {{ $}} + ; CHECK-NEXT: %lhs:_(s32) = COPY $s1 + ; CHECK-NEXT: %rhs:_(s32) = G_FCONSTANT float 1.000000e+00 + ; CHECK-NEXT: %select:_(s32) = G_FMAXIMUM %lhs, %rhs + ; CHECK-NEXT: $s0 = COPY %select(s32) + ; CHECK-NEXT: RET_ReallyLR implicit $s0 + %lhs:_(s32) = COPY $s1 + %rhs:_(s32) = G_FCONSTANT float 1.000000e+00 + %fcmp:_(s32) = G_FCMP floatpred(ult), %rhs(s32), %lhs + %select:_(s32) = G_SELECT %fcmp, %lhs, %rhs + $s0 = COPY %select + RET_ReallyLR implicit $s0 +... +--- +name: ule_fmaximum_rhs_safe +alignment: 4 +legalized: true +tracksRegLiveness: true +body: | + bb.1.entry: + liveins: $s0, $s1 + ; CHECK-LABEL: name: ule_fmaximum_rhs_safe + ; CHECK: liveins: $s0, $s1 + ; CHECK-NEXT: {{ $}} + ; CHECK-NEXT: %lhs:_(s32) = COPY $s1 + ; CHECK-NEXT: %rhs:_(s32) = G_FCONSTANT float 1.000000e+00 + ; CHECK-NEXT: %select:_(s32) = G_FMAXIMUM %lhs, %rhs + ; CHECK-NEXT: $s0 = COPY %select(s32) + ; CHECK-NEXT: RET_ReallyLR implicit $s0 + %lhs:_(s32) = COPY $s1 + %rhs:_(s32) = G_FCONSTANT float 1.000000e+00 + %fcmp:_(s32) = G_FCMP floatpred(ule), %rhs(s32), %lhs + %select:_(s32) = G_SELECT %fcmp, %lhs, %rhs + $s0 = COPY %select + RET_ReallyLR implicit $s0 +################################################################################ +########################## G_FMINNUM Positive Cases ############################ +################################################################################ + +#################### LHS and RHS both known to not be NaN. ##################### +... +--- +name: ult_fminnum_lhs_rhs_safe +alignment: 4 +legalized: true +tracksRegLiveness: true +body: | + bb.1.entry: + liveins: $s0, $s1 + ; CHECK-LABEL: name: ult_fminnum_lhs_rhs_safe + ; CHECK: liveins: $s0, $s1 + ; CHECK-NEXT: {{ $}} + ; CHECK-NEXT: %copy:_(s32) = COPY $s0 + ; CHECK-NEXT: %lhs:_(s32) = nnan G_FFLOOR %copy + ; CHECK-NEXT: %rhs:_(s32) = G_FCONSTANT float 1.000000e+00 + ; CHECK-NEXT: %select:_(s32) = G_FMINNUM %lhs, %rhs + ; CHECK-NEXT: $s0 = COPY %select(s32) + ; CHECK-NEXT: RET_ReallyLR implicit $s0 + %copy:_(s32) = COPY $s0 + %lhs:_(s32) = nnan G_FFLOOR %copy + %rhs:_(s32) = G_FCONSTANT float 1.0 + %fcmp:_(s32) = G_FCMP floatpred(ult), %lhs(s32), %rhs + %select:_(s32) = G_SELECT %fcmp, %lhs, %rhs + $s0 = COPY %select + RET_ReallyLR implicit $s0 + +... +--- +name: ule_fminnum_lhs_rhs_safe +alignment: 4 +legalized: true +tracksRegLiveness: true +body: | + bb.1.entry: + liveins: $s0, $s1 + ; CHECK-LABEL: name: ule_fminnum_lhs_rhs_safe + ; CHECK: liveins: $s0, $s1 + ; CHECK-NEXT: {{ $}} + ; CHECK-NEXT: %copy:_(s32) = COPY $s0 + ; CHECK-NEXT: %lhs:_(s32) = nnan G_FFLOOR %copy + ; CHECK-NEXT: %rhs:_(s32) = G_FCONSTANT float 1.000000e+00 + ; CHECK-NEXT: %select:_(s32) = G_FMINNUM %lhs, %rhs + ; CHECK-NEXT: $s0 = COPY %select(s32) + ; CHECK-NEXT: RET_ReallyLR implicit $s0 + %copy:_(s32) = COPY $s0 + %lhs:_(s32) = nnan G_FFLOOR %copy + %rhs:_(s32) = G_FCONSTANT float 1.0 + %fcmp:_(s32) = G_FCMP floatpred(ule), %lhs(s32), %rhs + %select:_(s32) = G_SELECT %fcmp, %lhs, %rhs + $s0 = COPY %select + RET_ReallyLR implicit $s0 + +... +--- +name: olt_fminnum_lhs_rhs_safe +alignment: 4 +legalized: true +tracksRegLiveness: true +body: | + bb.1.entry: + liveins: $s0, $s1 + ; CHECK-LABEL: name: olt_fminnum_lhs_rhs_safe + ; CHECK: liveins: $s0, $s1 + ; CHECK-NEXT: {{ $}} + ; CHECK-NEXT: %copy:_(s32) = COPY $s0 + ; CHECK-NEXT: %lhs:_(s32) = nnan G_FFLOOR %copy + ; CHECK-NEXT: %rhs:_(s32) = G_FCONSTANT float 1.000000e+00 + ; CHECK-NEXT: %select:_(s32) = G_FMINNUM %lhs, %rhs + ; CHECK-NEXT: $s0 = COPY %select(s32) + ; CHECK-NEXT: RET_ReallyLR implicit $s0 + %copy:_(s32) = COPY $s0 + %lhs:_(s32) = nnan G_FFLOOR %copy + %rhs:_(s32) = G_FCONSTANT float 1.0 + %fcmp:_(s32) = G_FCMP floatpred(olt), %lhs(s32), %rhs + %select:_(s32) = G_SELECT %fcmp, %lhs, %rhs + $s0 = COPY %select + RET_ReallyLR implicit $s0 + +... +--- +name: ole_fminnum_lhs_rhs_safe +alignment: 4 +legalized: true +tracksRegLiveness: true +body: | + bb.1.entry: + liveins: $s0, $s1 + ; CHECK-LABEL: name: ole_fminnum_lhs_rhs_safe + ; CHECK: liveins: $s0, $s1 + ; CHECK-NEXT: {{ $}} + ; CHECK-NEXT: %copy:_(s32) = COPY $s0 + ; CHECK-NEXT: %lhs:_(s32) = nnan G_FFLOOR %copy + ; CHECK-NEXT: %rhs:_(s32) = G_FCONSTANT float 1.000000e+00 + ; CHECK-NEXT: %select:_(s32) = G_FMINNUM %lhs, %rhs + ; CHECK-NEXT: $s0 = COPY %select(s32) + ; CHECK-NEXT: RET_ReallyLR implicit $s0 + %copy:_(s32) = COPY $s0 + %lhs:_(s32) = nnan G_FFLOOR %copy + %rhs:_(s32) = G_FCONSTANT float 1.0 + %fcmp:_(s32) = G_FCMP floatpred(ole), %lhs(s32), %rhs + %select:_(s32) = G_SELECT %fcmp, %lhs, %rhs + $s0 = COPY %select + RET_ReallyLR implicit $s0 + +#################### Unordered preds, LHS known non-NaN. ####################### +... +--- +name: ult_fminnum_lhs_safe +alignment: 4 +legalized: true +tracksRegLiveness: true +body: | + bb.1.entry: + liveins: $s0, $s1 + ; CHECK-LABEL: name: ult_fminnum_lhs_safe + ; CHECK: liveins: $s0, $s1 + ; CHECK-NEXT: {{ $}} + ; CHECK-NEXT: %lhs:_(s32) = G_FCONSTANT float 3.000000e+00 + ; CHECK-NEXT: %rhs:_(s32) = COPY $s1 + ; CHECK-NEXT: %select:_(s32) = G_FMINNUM %lhs, %rhs + ; CHECK-NEXT: $s0 = COPY %select(s32) + ; CHECK-NEXT: RET_ReallyLR implicit $s0 + %lhs:_(s32) = G_FCONSTANT float 3.0 + %rhs:_(s32) = COPY $s1 + %fcmp:_(s32) = G_FCMP floatpred(ult), %lhs(s32), %rhs + %select:_(s32) = G_SELECT %fcmp, %lhs, %rhs + $s0 = COPY %select + RET_ReallyLR implicit $s0 + +... +--- +name: ule_fminnum_lhs_safe +alignment: 4 +legalized: true +tracksRegLiveness: true +body: | + bb.1.entry: + liveins: $s0, $s1 + ; CHECK-LABEL: name: ule_fminnum_lhs_safe + ; CHECK: liveins: $s0, $s1 + ; CHECK-NEXT: {{ $}} + ; CHECK-NEXT: %lhs:_(s32) = G_FCONSTANT float 3.000000e+00 + ; CHECK-NEXT: %rhs:_(s32) = COPY $s1 + ; CHECK-NEXT: %select:_(s32) = G_FMINNUM %lhs, %rhs + ; CHECK-NEXT: $s0 = COPY %select(s32) + ; CHECK-NEXT: RET_ReallyLR implicit $s0 + %lhs:_(s32) = G_FCONSTANT float 3.0 + %rhs:_(s32) = COPY $s1 + %fcmp:_(s32) = G_FCMP floatpred(ule), %lhs(s32), %rhs + %select:_(s32) = G_SELECT %fcmp, %lhs, %rhs + $s0 = COPY %select + RET_ReallyLR implicit $s0 + +##################### Ordered preds, RHS known non-NaN. ######################## +... +--- +name: olt_fminnum_rhs_safe +alignment: 4 +legalized: true +tracksRegLiveness: true +body: | + bb.1.entry: + liveins: $s0, $s1 + ; CHECK-LABEL: name: olt_fminnum_rhs_safe + ; CHECK: liveins: $s0, $s1 + ; CHECK-NEXT: {{ $}} + ; CHECK-NEXT: %lhs:_(s32) = COPY $s1 + ; CHECK-NEXT: %rhs:_(s32) = G_FCONSTANT float 3.000000e+00 + ; CHECK-NEXT: %select:_(s32) = G_FMINNUM %lhs, %rhs + ; CHECK-NEXT: $s0 = COPY %select(s32) + ; CHECK-NEXT: RET_ReallyLR implicit $s0 + %lhs:_(s32) = COPY $s1 + %rhs:_(s32) = G_FCONSTANT float 3.0 + %fcmp:_(s32) = G_FCMP floatpred(olt), %lhs(s32), %rhs + %select:_(s32) = G_SELECT %fcmp, %lhs, %rhs + $s0 = COPY %select + RET_ReallyLR implicit $s0 + +... +--- +name: ole_fminnum_rhs_safe +alignment: 4 +legalized: true +tracksRegLiveness: true +body: | + bb.1.entry: + liveins: $s0, $s1 + ; CHECK-LABEL: name: ole_fminnum_rhs_safe + ; CHECK: liveins: $s0, $s1 + ; CHECK-NEXT: {{ $}} + ; CHECK-NEXT: %lhs:_(s32) = COPY $s1 + ; CHECK-NEXT: %rhs:_(s32) = G_FCONSTANT float 3.000000e+00 + ; CHECK-NEXT: %select:_(s32) = G_FMINNUM %lhs, %rhs + ; CHECK-NEXT: $s0 = COPY %select(s32) + ; CHECK-NEXT: RET_ReallyLR implicit $s0 + %lhs:_(s32) = COPY $s1 + %rhs:_(s32) = G_FCONSTANT float 3.0 + %fcmp:_(s32) = G_FCMP floatpred(ole), %lhs(s32), %rhs + %select:_(s32) = G_SELECT %fcmp, %lhs, %rhs + $s0 = COPY %select + RET_ReallyLR implicit $s0 + +############################## Swapped operands ################################ +... +--- +name: ugt_fminnum_lhs_safe +alignment: 4 +legalized: true +tracksRegLiveness: true +body: | + bb.1.entry: + liveins: $s0, $s1 + ; CHECK-LABEL: name: ugt_fminnum_lhs_safe + ; CHECK: liveins: $s0, $s1 + ; CHECK-NEXT: {{ $}} + ; CHECK-NEXT: %lhs:_(s32) = G_FCONSTANT float 1.000000e+00 + ; CHECK-NEXT: %rhs:_(s32) = COPY $s1 + ; CHECK-NEXT: %select:_(s32) = G_FMINNUM %lhs, %rhs + ; CHECK-NEXT: $s0 = COPY %select(s32) + ; CHECK-NEXT: RET_ReallyLR implicit $s0 + %lhs:_(s32) = G_FCONSTANT float 1.000000e+00 + %rhs:_(s32) = COPY $s1 + %fcmp:_(s32) = G_FCMP floatpred(ugt), %rhs(s32), %lhs + %select:_(s32) = G_SELECT %fcmp, %lhs, %rhs + $s0 = COPY %select + RET_ReallyLR implicit $s0 +... +--- +name: uge_fminnum_lhs_safe +alignment: 4 +legalized: true +tracksRegLiveness: true +body: | + bb.1.entry: + liveins: $s0, $s1 + ; CHECK-LABEL: name: uge_fminnum_lhs_safe + ; CHECK: liveins: $s0, $s1 + ; CHECK-NEXT: {{ $}} + ; CHECK-NEXT: %lhs:_(s32) = G_FCONSTANT float 1.000000e+00 + ; CHECK-NEXT: %rhs:_(s32) = COPY $s1 + ; CHECK-NEXT: %select:_(s32) = G_FMINNUM %lhs, %rhs + ; CHECK-NEXT: $s0 = COPY %select(s32) + ; CHECK-NEXT: RET_ReallyLR implicit $s0 + %lhs:_(s32) = G_FCONSTANT float 1.000000e+00 + %rhs:_(s32) = COPY $s1 + %fcmp:_(s32) = G_FCMP floatpred(uge), %rhs(s32), %lhs + %select:_(s32) = G_SELECT %fcmp, %lhs, %rhs + $s0 = COPY %select + RET_ReallyLR implicit $s0 +... +--- +name: oge_fminnum_rhs_safe +alignment: 4 +legalized: true +tracksRegLiveness: true +body: | + bb.1.entry: + liveins: $s0, $s1 + ; CHECK-LABEL: name: oge_fminnum_rhs_safe + ; CHECK: liveins: $s0, $s1 + ; CHECK-NEXT: {{ $}} + ; CHECK-NEXT: %lhs:_(s32) = COPY $s1 + ; CHECK-NEXT: %rhs:_(s32) = G_FCONSTANT float 1.000000e+00 + ; CHECK-NEXT: %select:_(s32) = G_FMINNUM %lhs, %rhs + ; CHECK-NEXT: $s0 = COPY %select(s32) + ; CHECK-NEXT: RET_ReallyLR implicit $s0 + %lhs:_(s32) = COPY $s1 + %rhs:_(s32) = G_FCONSTANT float 1.000000e+00 + %fcmp:_(s32) = G_FCMP floatpred(oge), %rhs(s32), %lhs + %select:_(s32) = G_SELECT %fcmp, %lhs, %rhs + $s0 = COPY %select + RET_ReallyLR implicit $s0 +... +--- +name: ogt_fminnum_rhs_safe +alignment: 4 +legalized: true +tracksRegLiveness: true +body: | + bb.1.entry: + liveins: $s0, $s1 + ; CHECK-LABEL: name: ogt_fminnum_rhs_safe + ; CHECK: liveins: $s0, $s1 + ; CHECK-NEXT: {{ $}} + ; CHECK-NEXT: %lhs:_(s32) = COPY $s1 + ; CHECK-NEXT: %rhs:_(s32) = G_FCONSTANT float 1.000000e+00 + ; CHECK-NEXT: %select:_(s32) = G_FMINNUM %lhs, %rhs + ; CHECK-NEXT: $s0 = COPY %select(s32) + ; CHECK-NEXT: RET_ReallyLR implicit $s0 + %lhs:_(s32) = COPY $s1 + %rhs:_(s32) = G_FCONSTANT float 1.000000e+00 + %fcmp:_(s32) = G_FCMP floatpred(ogt), %rhs(s32), %lhs + %select:_(s32) = G_SELECT %fcmp, %lhs, %rhs + $s0 = COPY %select + RET_ReallyLR implicit $s0 + + +################################################################################ +########################## G_FMINIMUM Positive Cases ########################### +################################################################################ + +#################### Unordered preds, RHS known non-NaN. ####################### +... +--- +name: ult_fminimum_rhs_safe +alignment: 4 +legalized: true +tracksRegLiveness: true +body: | + bb.1.entry: + liveins: $s0, $s1 + ; CHECK-LABEL: name: ult_fminimum_rhs_safe + ; CHECK: liveins: $s0, $s1 + ; CHECK-NEXT: {{ $}} + ; CHECK-NEXT: %lhs:_(s32) = COPY $s1 + ; CHECK-NEXT: %rhs:_(s32) = G_FCONSTANT float 3.000000e+00 + ; CHECK-NEXT: %select:_(s32) = G_FMINIMUM %lhs, %rhs + ; CHECK-NEXT: $s0 = COPY %select(s32) + ; CHECK-NEXT: RET_ReallyLR implicit $s0 + %lhs:_(s32) = COPY $s1 + %rhs:_(s32) = G_FCONSTANT float 3.0 + %fcmp:_(s32) = G_FCMP floatpred(ult), %lhs(s32), %rhs + %select:_(s32) = G_SELECT %fcmp, %lhs, %rhs + $s0 = COPY %select + RET_ReallyLR implicit $s0 + +... +--- +name: ule_fminimum_rhs_safe +alignment: 4 +legalized: true +tracksRegLiveness: true +body: | + bb.1.entry: + liveins: $s0, $s1 + ; CHECK-LABEL: name: ule_fminimum_rhs_safe + ; CHECK: liveins: $s0, $s1 + ; CHECK-NEXT: {{ $}} + ; CHECK-NEXT: %lhs:_(s32) = COPY $s1 + ; CHECK-NEXT: %rhs:_(s32) = G_FCONSTANT float 3.000000e+00 + ; CHECK-NEXT: %select:_(s32) = G_FMINIMUM %lhs, %rhs + ; CHECK-NEXT: $s0 = COPY %select(s32) + ; CHECK-NEXT: RET_ReallyLR implicit $s0 + %lhs:_(s32) = COPY $s1 + %rhs:_(s32) = G_FCONSTANT float 3.0 + %fcmp:_(s32) = G_FCMP floatpred(ule), %lhs(s32), %rhs + %select:_(s32) = G_SELECT %fcmp, %lhs, %rhs + $s0 = COPY %select + RET_ReallyLR implicit $s0 + +##################### Ordered preds, LHS known non-NaN. ######################## +... +--- +name: olt_fminimum_lhs_safe +alignment: 4 +legalized: true +tracksRegLiveness: true +body: | + bb.1.entry: + liveins: $s0, $s1 + ; CHECK-LABEL: name: olt_fminimum_lhs_safe + ; CHECK: liveins: $s0, $s1 + ; CHECK-NEXT: {{ $}} + ; CHECK-NEXT: %lhs:_(s32) = G_FCONSTANT float 3.000000e+00 + ; CHECK-NEXT: %rhs:_(s32) = COPY $s1 + ; CHECK-NEXT: %select:_(s32) = G_FMINIMUM %lhs, %rhs + ; CHECK-NEXT: $s0 = COPY %select(s32) + ; CHECK-NEXT: RET_ReallyLR implicit $s0 + %lhs:_(s32) = G_FCONSTANT float 3.0 + %rhs:_(s32) = COPY $s1 + %fcmp:_(s32) = G_FCMP floatpred(olt), %lhs(s32), %rhs + %select:_(s32) = G_SELECT %fcmp, %lhs, %rhs + $s0 = COPY %select + RET_ReallyLR implicit $s0 + +... +--- +name: ole_fminimum_lhs_safe +alignment: 4 +legalized: true +tracksRegLiveness: true +body: | + bb.1.entry: + liveins: $s0, $s1 + ; CHECK-LABEL: name: ole_fminimum_lhs_safe + ; CHECK: liveins: $s0, $s1 + ; CHECK-NEXT: {{ $}} + ; CHECK-NEXT: %lhs:_(s32) = G_FCONSTANT float 3.000000e+00 + ; CHECK-NEXT: %rhs:_(s32) = COPY $s1 + ; CHECK-NEXT: %select:_(s32) = G_FMINIMUM %lhs, %rhs + ; CHECK-NEXT: $s0 = COPY %select(s32) + ; CHECK-NEXT: RET_ReallyLR implicit $s0 + %lhs:_(s32) = G_FCONSTANT float 3.0 + %rhs:_(s32) = COPY $s1 + %fcmp:_(s32) = G_FCMP floatpred(ole), %lhs(s32), %rhs + %select:_(s32) = G_SELECT %fcmp, %lhs, %rhs + $s0 = COPY %select + RET_ReallyLR implicit $s0 + +############################## Swapped operands ################################ +... +--- +name: oge_fminimum_lhs_safe +alignment: 4 +legalized: true +tracksRegLiveness: true +body: | + bb.1.entry: + liveins: $s0, $s1 + ; CHECK-LABEL: name: oge_fminimum_lhs_safe + ; CHECK: liveins: $s0, $s1 + ; CHECK-NEXT: {{ $}} + ; CHECK-NEXT: %lhs:_(s32) = G_FCONSTANT float 1.000000e+00 + ; CHECK-NEXT: %rhs:_(s32) = COPY $s1 + ; CHECK-NEXT: %select:_(s32) = G_FMINIMUM %lhs, %rhs + ; CHECK-NEXT: $s0 = COPY %select(s32) + ; CHECK-NEXT: RET_ReallyLR implicit $s0 + %lhs:_(s32) = G_FCONSTANT float 1.000000e+00 + %rhs:_(s32) = COPY $s1 + %fcmp:_(s32) = G_FCMP floatpred(oge), %rhs(s32), %lhs + %select:_(s32) = G_SELECT %fcmp, %lhs, %rhs + $s0 = COPY %select + RET_ReallyLR implicit $s0 +... +--- +name: ogt_fminimum_lhs_safe +alignment: 4 +legalized: true +tracksRegLiveness: true +body: | + bb.1.entry: + liveins: $s0, $s1 + ; CHECK-LABEL: name: ogt_fminimum_lhs_safe + ; CHECK: liveins: $s0, $s1 + ; CHECK-NEXT: {{ $}} + ; CHECK-NEXT: %lhs:_(s32) = G_FCONSTANT float 1.000000e+00 + ; CHECK-NEXT: %rhs:_(s32) = COPY $s1 + ; CHECK-NEXT: %select:_(s32) = G_FMINIMUM %lhs, %rhs + ; CHECK-NEXT: $s0 = COPY %select(s32) + ; CHECK-NEXT: RET_ReallyLR implicit $s0 + %lhs:_(s32) = G_FCONSTANT float 1.000000e+00 + %rhs:_(s32) = COPY $s1 + %fcmp:_(s32) = G_FCMP floatpred(ogt), %rhs(s32), %lhs + %select:_(s32) = G_SELECT %fcmp, %lhs, %rhs + $s0 = COPY %select + RET_ReallyLR implicit $s0 +... +--- +name: ugt_fminimum_rhs_safe +alignment: 4 +legalized: true +tracksRegLiveness: true +body: | + bb.1.entry: + liveins: $s0, $s1 + ; CHECK-LABEL: name: ugt_fminimum_rhs_safe + ; CHECK: liveins: $s0, $s1 + ; CHECK-NEXT: {{ $}} + ; CHECK-NEXT: %lhs:_(s32) = COPY $s1 + ; CHECK-NEXT: %rhs:_(s32) = G_FCONSTANT float 1.000000e+00 + ; CHECK-NEXT: %select:_(s32) = G_FMINIMUM %lhs, %rhs + ; CHECK-NEXT: $s0 = COPY %select(s32) + ; CHECK-NEXT: RET_ReallyLR implicit $s0 + %lhs:_(s32) = COPY $s1 + %rhs:_(s32) = G_FCONSTANT float 1.000000e+00 + %fcmp:_(s32) = G_FCMP floatpred(ugt), %rhs(s32), %lhs + %select:_(s32) = G_SELECT %fcmp, %lhs, %rhs + $s0 = COPY %select + RET_ReallyLR implicit $s0 +... +--- +name: uge_fminimum_rhs_safe +alignment: 4 +legalized: true +tracksRegLiveness: true +body: | + bb.1.entry: + liveins: $s0, $s1 + ; CHECK-LABEL: name: uge_fminimum_rhs_safe + ; CHECK: liveins: $s0, $s1 + ; CHECK-NEXT: {{ $}} + ; CHECK-NEXT: %lhs:_(s32) = COPY $s1 + ; CHECK-NEXT: %rhs:_(s32) = G_FCONSTANT float 1.000000e+00 + ; CHECK-NEXT: %select:_(s32) = G_FMINIMUM %lhs, %rhs + ; CHECK-NEXT: $s0 = COPY %select(s32) + ; CHECK-NEXT: RET_ReallyLR implicit $s0 + %lhs:_(s32) = COPY $s1 + %rhs:_(s32) = G_FCONSTANT float 1.000000e+00 + %fcmp:_(s32) = G_FCMP floatpred(uge), %rhs(s32), %lhs + %select:_(s32) = G_SELECT %fcmp, %lhs, %rhs + $s0 = COPY %select + RET_ReallyLR implicit $s0 + +################################################################################ +########################## Other Positive Cases ################################ +################################################################################ + +... +--- +name: ugt_fmaxnum_rhs_safe +alignment: 4 +legalized: true +tracksRegLiveness: true +body: | + bb.1.entry: + liveins: $s0, $s1 + ; CHECK-LABEL: name: ugt_fmaxnum_rhs_safe + ; CHECK: liveins: $s0, $s1 + ; CHECK-NEXT: {{ $}} + ; CHECK-NEXT: %lhs:_(s32) = COPY $s0 + ; CHECK-NEXT: %rhs:_(s32) = G_FCONSTANT float 1.000000e+00 + ; CHECK-NEXT: %select:_(s32) = G_FMAXIMUM %lhs, %rhs + ; CHECK-NEXT: $s0 = COPY %select(s32) + ; CHECK-NEXT: RET_ReallyLR implicit $s0 + %lhs:_(s32) = COPY $s0 + %rhs:_(s32) = G_FCONSTANT float 1.0 + %fcmp:_(s32) = G_FCMP floatpred(ugt), %lhs(s32), %rhs + %select:_(s32) = G_SELECT %fcmp, %lhs, %rhs + $s0 = COPY %select + RET_ReallyLR implicit $s0 + +... +--- +name: fmaximum_pos_zero_defined +alignment: 4 +legalized: true +tracksRegLiveness: true +body: | + bb.1.entry: + liveins: $s0, $s1 + ; CHECK-LABEL: name: fmaximum_pos_zero_defined + ; CHECK: liveins: $s0, $s1 + ; CHECK-NEXT: {{ $}} + ; CHECK-NEXT: %lhs:_(s32) = COPY $s0 + ; CHECK-NEXT: %rhs:_(s32) = G_FCONSTANT float 0.000000e+00 + ; CHECK-NEXT: %select:_(s32) = G_FMAXIMUM %lhs, %rhs + ; CHECK-NEXT: $s0 = COPY %select(s32) + ; CHECK-NEXT: RET_ReallyLR implicit $s0 + %lhs:_(s32) = COPY $s0 + %rhs:_(s32) = G_FCONSTANT float 0.0 + %fcmp:_(s32) = G_FCMP floatpred(ugt), %lhs(s32), %rhs + %select:_(s32) = G_SELECT %fcmp, %lhs, %rhs + $s0 = COPY %select + RET_ReallyLR implicit $s0 +... +--- +name: fmaximum_neg_zero_defined +alignment: 4 +legalized: true +tracksRegLiveness: true +body: | + bb.1.entry: + liveins: $s0, $s1 + ; CHECK-LABEL: name: fmaximum_neg_zero_defined + ; CHECK: liveins: $s0, $s1 + ; CHECK-NEXT: {{ $}} + ; CHECK-NEXT: %lhs:_(s32) = COPY $s0 + ; CHECK-NEXT: %rhs:_(s32) = G_FCONSTANT float -0.000000e+00 + ; CHECK-NEXT: %select:_(s32) = G_FMAXIMUM %lhs, %rhs + ; CHECK-NEXT: $s0 = COPY %select(s32) + ; CHECK-NEXT: RET_ReallyLR implicit $s0 + %lhs:_(s32) = COPY $s0 + %rhs:_(s32) = G_FCONSTANT float -0.0 + %fcmp:_(s32) = G_FCMP floatpred(ugt), %lhs(s32), %rhs + %select:_(s32) = G_SELECT %fcmp, %lhs, %rhs + $s0 = COPY %select + RET_ReallyLR implicit $s0 +... +--- +name: fmaximum_zero_rhs +alignment: 4 +legalized: true +tracksRegLiveness: true +body: | + bb.1.entry: + liveins: $s0, $s1 + ; CHECK-LABEL: name: fmaximum_zero_rhs + ; CHECK: liveins: $s0, $s1 + ; CHECK-NEXT: {{ $}} + ; CHECK-NEXT: %lhs:_(s32) = COPY $s0 + ; CHECK-NEXT: %rhs:_(s32) = G_FCONSTANT float 0.000000e+00 + ; CHECK-NEXT: %select:_(s32) = G_FMAXIMUM %lhs, %rhs + ; CHECK-NEXT: $s0 = COPY %select(s32) + ; CHECK-NEXT: RET_ReallyLR implicit $s0 + %lhs:_(s32) = COPY $s0 + %rhs:_(s32) = G_FCONSTANT float 0.0 + %fcmp:_(s32) = G_FCMP floatpred(ugt), %lhs(s32), %rhs + %select:_(s32) = G_SELECT %fcmp, %lhs, %rhs + $s0 = COPY %select + RET_ReallyLR implicit $s0 +... +--- +name: fminimum_pos_zero_defined +alignment: 4 +legalized: true +tracksRegLiveness: true +body: | + bb.1.entry: + liveins: $s0, $s1 + ; CHECK-LABEL: name: fminimum_pos_zero_defined + ; CHECK: liveins: $s0, $s1 + ; CHECK-NEXT: {{ $}} + ; CHECK-NEXT: %lhs:_(s32) = COPY $s0 + ; CHECK-NEXT: %rhs:_(s32) = G_FCONSTANT float 0.000000e+00 + ; CHECK-NEXT: %select:_(s32) = G_FMINIMUM %lhs, %rhs + ; CHECK-NEXT: $s0 = COPY %select(s32) + ; CHECK-NEXT: RET_ReallyLR implicit $s0 + %lhs:_(s32) = COPY $s0 + %rhs:_(s32) = G_FCONSTANT float 0.0 + %fcmp:_(s32) = G_FCMP floatpred(ult), %lhs(s32), %rhs + %select:_(s32) = G_SELECT %fcmp, %lhs, %rhs + $s0 = COPY %select + RET_ReallyLR implicit $s0 + +################################################################################ +########################## Negative Testcases ################################## +################################################################################ + +... +--- +name: dont_combine_vector +alignment: 4 +legalized: true +tracksRegLiveness: true +body: | + bb.1.entry: + liveins: $d0, $d1 + + + + ; CHECK-LABEL: name: dont_combine_vector + ; CHECK: liveins: $d0, $d1 + ; CHECK-NEXT: {{ $}} + ; CHECK-NEXT: %lhs:_(<2 x s32>) = COPY $d0 + ; CHECK-NEXT: %cst:_(s32) = G_FCONSTANT float 1.000000e+00 + ; CHECK-NEXT: %rhs:_(<2 x s32>) = G_BUILD_VECTOR %cst(s32), %cst(s32) + ; CHECK-NEXT: %fcmp:_(<2 x s32>) = G_FCMP floatpred(ugt), %lhs(<2 x s32>), %rhs + ; CHECK-NEXT: %select:_(<2 x s32>) = G_SELECT %fcmp(<2 x s32>), %lhs, %rhs + ; CHECK-NEXT: $d0 = COPY %select(<2 x s32>) + ; CHECK-NEXT: RET_ReallyLR implicit $d0 + %lhs:_(<2 x s32>) = COPY $d0 + %cst:_(s32) = G_FCONSTANT float 1.0 + %rhs:_(<2 x s32>) = G_BUILD_VECTOR %cst, %cst + %fcmp:_(<2 x s32>) = G_FCMP floatpred(ugt), %lhs(<2 x s32>), %rhs + %select:_(<2 x s32>) = G_SELECT %fcmp, %lhs, %rhs + $d0 = COPY %select + RET_ReallyLR implicit $d0 + +... +--- +name: dont_combine_pointer +alignment: 4 +legalized: true +tracksRegLiveness: true +body: | + bb.1.entry: + liveins: $x0, $x1 + ; CHECK-LABEL: name: dont_combine_pointer + ; CHECK: liveins: $x0, $x1 + ; CHECK-NEXT: {{ $}} + ; CHECK-NEXT: %lhs:_(p0) = COPY $x0 + ; CHECK-NEXT: %rhs:_(p0) = COPY $x1 + ; CHECK-NEXT: %fcmp:_(s32) = G_FCMP floatpred(ugt), %lhs(p0), %rhs + ; CHECK-NEXT: %select:_(p0) = G_SELECT %fcmp(s32), %lhs, %rhs + ; CHECK-NEXT: $d0 = COPY %select(p0) + ; CHECK-NEXT: RET_ReallyLR implicit $d0 + %lhs:_(p0) = COPY $x0 + %rhs:_(p0) = COPY $x1 + %fcmp:_(s32) = G_FCMP floatpred(ugt), %lhs(p0), %rhs + %select:_(p0) = G_SELECT %fcmp, %lhs, %rhs + $d0 = COPY %select + RET_ReallyLR implicit $d0 +... +--- +name: dont_combine_zero_lhs_rhs_unknown +alignment: 4 +legalized: true +tracksRegLiveness: true +body: | + bb.1.entry: + liveins: $s0, $s1 + ; CHECK-LABEL: name: dont_combine_zero_lhs_rhs_unknown + ; CHECK: liveins: $s0, $s1 + ; CHECK-NEXT: {{ $}} + ; CHECK-NEXT: %lhs:_(s32) = G_FCONSTANT float 0.000000e+00 + ; CHECK-NEXT: %rhs:_(s32) = COPY $s0 + ; CHECK-NEXT: %fcmp:_(s32) = G_FCMP floatpred(ugt), %lhs(s32), %rhs + ; CHECK-NEXT: %select:_(s32) = G_SELECT %fcmp(s32), %lhs, %rhs + ; CHECK-NEXT: $s0 = COPY %select(s32) + ; CHECK-NEXT: RET_ReallyLR implicit $s0 + %lhs:_(s32) = G_FCONSTANT float 0.0 + %rhs:_(s32) = COPY $s0 + %fcmp:_(s32) = G_FCMP floatpred(ugt), %lhs(s32), %rhs + %select:_(s32) = G_SELECT %fcmp, %lhs, %rhs + $s0 = COPY %select + RET_ReallyLR implicit $s0 +... +--- +name: dont_combine_lhs_rhs_unknown +alignment: 4 +legalized: true +tracksRegLiveness: true +body: | + bb.1.entry: + liveins: $s0, $s1 + ; CHECK-LABEL: name: dont_combine_lhs_rhs_unknown + ; CHECK: liveins: $s0, $s1 + ; CHECK-NEXT: {{ $}} + ; CHECK-NEXT: %lhs:_(s32) = COPY $s0 + ; CHECK-NEXT: %rhs:_(s32) = COPY $s1 + ; CHECK-NEXT: %fcmp:_(s32) = G_FCMP floatpred(ugt), %lhs(s32), %rhs + ; CHECK-NEXT: %select:_(s32) = G_SELECT %fcmp(s32), %lhs, %rhs + ; CHECK-NEXT: $s0 = COPY %select(s32) + ; CHECK-NEXT: RET_ReallyLR implicit $s0 + %lhs:_(s32) = COPY $s0 + %rhs:_(s32) = COPY $s1 + %fcmp:_(s32) = G_FCMP floatpred(ugt), %lhs(s32), %rhs + %select:_(s32) = G_SELECT %fcmp, %lhs, %rhs + $s0 = COPY %select + RET_ReallyLR implicit $s0 +... +--- +name: dont_combine_lhs_rhs_nan +alignment: 4 +legalized: true +tracksRegLiveness: true +body: | + bb.1.entry: + liveins: $s0, $s1 + ; CHECK-LABEL: name: dont_combine_lhs_rhs_nan + ; CHECK: liveins: $s0, $s1 + ; CHECK-NEXT: {{ $}} + ; CHECK-NEXT: %lhs:_(s32) = G_FCONSTANT float 0x7FF1000000000000 + ; CHECK-NEXT: %rhs:_(s32) = G_FCONSTANT float 0x7FF1000000000000 + ; CHECK-NEXT: %fcmp:_(s32) = G_FCMP floatpred(ugt), %lhs(s32), %rhs + ; CHECK-NEXT: %select:_(s32) = G_SELECT %fcmp(s32), %lhs, %rhs + ; CHECK-NEXT: $s0 = COPY %select(s32) + ; CHECK-NEXT: RET_ReallyLR implicit $s0 + %lhs:_(s32) = G_FCONSTANT float 0x7FF1000000000000 + %rhs:_(s32) = G_FCONSTANT float 0x7FF1000000000000 + %fcmp:_(s32) = G_FCMP floatpred(ugt), %lhs(s32), %rhs + %select:_(s32) = G_SELECT %fcmp, %lhs, %rhs + $s0 = COPY %select + RET_ReallyLR implicit $s0 +... +--- +name: dont_combine_different_lhs +alignment: 4 +legalized: true +tracksRegLiveness: true +body: | + bb.1.entry: + liveins: $s0, $s1 + ; CHECK-LABEL: name: dont_combine_different_lhs + ; CHECK: liveins: $s0, $s1 + ; CHECK-NEXT: {{ $}} + ; CHECK-NEXT: %select_lhs:_(s32) = G_FCONSTANT float 1.000000e+00 + ; CHECK-NEXT: %fcmp_lhs:_(s32) = G_FCONSTANT float 2.000000e+00 + ; CHECK-NEXT: %rhs:_(s32) = G_FCONSTANT float 3.000000e+00 + ; CHECK-NEXT: %fcmp:_(s32) = G_FCMP floatpred(ugt), %fcmp_lhs(s32), %rhs + ; CHECK-NEXT: %select:_(s32) = G_SELECT %fcmp(s32), %select_lhs, %rhs + ; CHECK-NEXT: $s0 = COPY %select(s32) + ; CHECK-NEXT: RET_ReallyLR implicit $s0 + %select_lhs:_(s32) = G_FCONSTANT float 1.0 + %fcmp_lhs:_(s32) = G_FCONSTANT float 2.0 + %rhs:_(s32) = G_FCONSTANT float 3.0 + %fcmp:_(s32) = G_FCMP floatpred(ugt), %fcmp_lhs(s32), %rhs + %select:_(s32) = G_SELECT %fcmp, %select_lhs, %rhs + $s0 = COPY %select + RET_ReallyLR implicit $s0 +... +--- +name: dont_combine_oeq +alignment: 4 +legalized: true +tracksRegLiveness: true +body: | + bb.1.entry: + liveins: $s0, $s1 + ; CHECK-LABEL: name: dont_combine_oeq + ; CHECK: liveins: $s0, $s1 + ; CHECK-NEXT: {{ $}} + ; CHECK-NEXT: %lhs:_(s32) = G_FCONSTANT float 3.000000e+00 + ; CHECK-NEXT: %rhs:_(s32) = G_FCONSTANT float 2.000000e+00 + ; CHECK-NEXT: %fcmp:_(s32) = G_FCMP floatpred(oeq), %lhs(s32), %rhs + ; CHECK-NEXT: %select:_(s32) = G_SELECT %fcmp(s32), %lhs, %rhs + ; CHECK-NEXT: $s0 = COPY %select(s32) + ; CHECK-NEXT: RET_ReallyLR implicit $s0 + %lhs:_(s32) = G_FCONSTANT float 3.0 + %rhs:_(s32) = G_FCONSTANT float 2.0 + %fcmp:_(s32) = G_FCMP floatpred(oeq), %lhs(s32), %rhs + %select:_(s32) = G_SELECT %fcmp, %lhs, %rhs + $s0 = COPY %select + RET_ReallyLR implicit $s0 +... +--- +name: dont_combine_ueq +alignment: 4 +legalized: true +tracksRegLiveness: true +body: | + bb.1.entry: + liveins: $s0, $s1 + ; CHECK-LABEL: name: dont_combine_ueq + ; CHECK: liveins: $s0, $s1 + ; CHECK-NEXT: {{ $}} + ; CHECK-NEXT: %lhs:_(s32) = G_FCONSTANT float 3.000000e+00 + ; CHECK-NEXT: %rhs:_(s32) = G_FCONSTANT float 2.000000e+00 + ; CHECK-NEXT: %fcmp:_(s32) = G_FCMP floatpred(ueq), %lhs(s32), %rhs + ; CHECK-NEXT: %select:_(s32) = G_SELECT %fcmp(s32), %lhs, %rhs + ; CHECK-NEXT: $s0 = COPY %select(s32) + ; CHECK-NEXT: RET_ReallyLR implicit $s0 + %lhs:_(s32) = G_FCONSTANT float 3.0 + %rhs:_(s32) = G_FCONSTANT float 2.0 + %fcmp:_(s32) = G_FCMP floatpred(ueq), %lhs(s32), %rhs + %select:_(s32) = G_SELECT %fcmp, %lhs, %rhs + $s0 = COPY %select + RET_ReallyLR implicit $s0 +... +--- +name: dont_combine_one +alignment: 4 +legalized: true +tracksRegLiveness: true +body: | + bb.1.entry: + liveins: $s0, $s1 + ; CHECK-LABEL: name: dont_combine_one + ; CHECK: liveins: $s0, $s1 + ; CHECK-NEXT: {{ $}} + ; CHECK-NEXT: %lhs:_(s32) = G_FCONSTANT float 3.000000e+00 + ; CHECK-NEXT: %rhs:_(s32) = G_FCONSTANT float 2.000000e+00 + ; CHECK-NEXT: %fcmp:_(s32) = G_FCMP floatpred(one), %lhs(s32), %rhs + ; CHECK-NEXT: %select:_(s32) = G_SELECT %fcmp(s32), %lhs, %rhs + ; CHECK-NEXT: $s0 = COPY %select(s32) + ; CHECK-NEXT: RET_ReallyLR implicit $s0 + %lhs:_(s32) = G_FCONSTANT float 3.0 + %rhs:_(s32) = G_FCONSTANT float 2.0 + %fcmp:_(s32) = G_FCMP floatpred(one), %lhs(s32), %rhs + %select:_(s32) = G_SELECT %fcmp, %lhs, %rhs + $s0 = COPY %select + RET_ReallyLR implicit $s0 +... +--- +name: dont_combine_une +alignment: 4 +legalized: true +tracksRegLiveness: true +body: | + bb.1.entry: + liveins: $s0, $s1 + ; CHECK-LABEL: name: dont_combine_une + ; CHECK: liveins: $s0, $s1 + ; CHECK-NEXT: {{ $}} + ; CHECK-NEXT: %lhs:_(s32) = G_FCONSTANT float 3.000000e+00 + ; CHECK-NEXT: %rhs:_(s32) = G_FCONSTANT float 2.000000e+00 + ; CHECK-NEXT: %fcmp:_(s32) = G_FCMP floatpred(une), %lhs(s32), %rhs + ; CHECK-NEXT: %select:_(s32) = G_SELECT %fcmp(s32), %lhs, %rhs + ; CHECK-NEXT: $s0 = COPY %select(s32) + ; CHECK-NEXT: RET_ReallyLR implicit $s0 + %lhs:_(s32) = G_FCONSTANT float 3.0 + %rhs:_(s32) = G_FCONSTANT float 2.0 + %fcmp:_(s32) = G_FCMP floatpred(une), %lhs(s32), %rhs + %select:_(s32) = G_SELECT %fcmp, %lhs, %rhs + $s0 = COPY %select + RET_ReallyLR implicit $s0 +... +--- +name: dont_combine_to_fmaxnum_zero +alignment: 4 +legalized: true +tracksRegLiveness: true +body: | + bb.1.entry: + liveins: $s0, $s1 + ; CHECK-LABEL: name: dont_combine_to_fmaxnum_zero + ; CHECK: liveins: $s0, $s1 + ; CHECK-NEXT: {{ $}} + ; CHECK-NEXT: %lhs:_(s32) = COPY $s0 + ; CHECK-NEXT: %rhs:_(s32) = G_FCONSTANT float 0.000000e+00 + ; CHECK-NEXT: %fcmp:_(s32) = G_FCMP floatpred(ogt), %lhs(s32), %rhs + ; CHECK-NEXT: %select:_(s32) = G_SELECT %fcmp(s32), %lhs, %rhs + ; CHECK-NEXT: $s0 = COPY %select(s32) + ; CHECK-NEXT: RET_ReallyLR implicit $s0 + %lhs:_(s32) = COPY $s0 + %rhs:_(s32) = G_FCONSTANT float 0.0 + %fcmp:_(s32) = G_FCMP floatpred(ogt), %lhs(s32), %rhs + %select:_(s32) = G_SELECT %fcmp, %lhs, %rhs + $s0 = COPY %select + RET_ReallyLR implicit $s0 +... +--- +name: dont_combine_to_fmaxnum_neg_zero +alignment: 4 +legalized: true +tracksRegLiveness: true +body: | + bb.1.entry: + liveins: $s0, $s1 + ; CHECK-LABEL: name: dont_combine_to_fmaxnum_neg_zero + ; CHECK: liveins: $s0, $s1 + ; CHECK-NEXT: {{ $}} + ; CHECK-NEXT: %lhs:_(s32) = COPY $s0 + ; CHECK-NEXT: %rhs:_(s32) = G_FCONSTANT float -0.000000e+00 + ; CHECK-NEXT: %fcmp:_(s32) = G_FCMP floatpred(ogt), %lhs(s32), %rhs + ; CHECK-NEXT: %select:_(s32) = G_SELECT %fcmp(s32), %lhs, %rhs + ; CHECK-NEXT: $s0 = COPY %select(s32) + ; CHECK-NEXT: RET_ReallyLR implicit $s0 + %lhs:_(s32) = COPY $s0 + %rhs:_(s32) = G_FCONSTANT float -0.0 + %fcmp:_(s32) = G_FCMP floatpred(ogt), %lhs(s32), %rhs + %select:_(s32) = G_SELECT %fcmp, %lhs, %rhs + $s0 = COPY %select + RET_ReallyLR implicit $s0 +... +--- +name: dont_combine_to_fminnum_zero +alignment: 4 +legalized: true +tracksRegLiveness: true +body: | + bb.1.entry: + liveins: $s0, $s1 + ; CHECK-LABEL: name: dont_combine_to_fminnum_zero + ; CHECK: liveins: $s0, $s1 + ; CHECK-NEXT: {{ $}} + ; CHECK-NEXT: %lhs:_(s32) = COPY $s0 + ; CHECK-NEXT: %rhs:_(s32) = G_FCONSTANT float 0.000000e+00 + ; CHECK-NEXT: %fcmp:_(s32) = G_FCMP floatpred(olt), %lhs(s32), %rhs + ; CHECK-NEXT: %select:_(s32) = G_SELECT %fcmp(s32), %lhs, %rhs + ; CHECK-NEXT: $s0 = COPY %select(s32) + ; CHECK-NEXT: RET_ReallyLR implicit $s0 + %lhs:_(s32) = COPY $s0 + %rhs:_(s32) = G_FCONSTANT float 0.0 + %fcmp:_(s32) = G_FCMP floatpred(olt), %lhs(s32), %rhs + %select:_(s32) = G_SELECT %fcmp, %lhs, %rhs + $s0 = COPY %select + RET_ReallyLR implicit $s0 +... +--- +name: dont_combine_to_fminnum_neg_zero +alignment: 4 +legalized: true +tracksRegLiveness: true +body: | + bb.1.entry: + liveins: $s0, $s1 + ; CHECK-LABEL: name: dont_combine_to_fminnum_neg_zero + ; CHECK: liveins: $s0, $s1 + ; CHECK-NEXT: {{ $}} + ; CHECK-NEXT: %lhs:_(s32) = COPY $s0 + ; CHECK-NEXT: %rhs:_(s32) = G_FCONSTANT float -0.000000e+00 + ; CHECK-NEXT: %fcmp:_(s32) = G_FCMP floatpred(olt), %lhs(s32), %rhs + ; CHECK-NEXT: %select:_(s32) = G_SELECT %fcmp(s32), %lhs, %rhs + ; CHECK-NEXT: $s0 = COPY %select(s32) + ; CHECK-NEXT: RET_ReallyLR implicit $s0 + %lhs:_(s32) = COPY $s0 + %rhs:_(s32) = G_FCONSTANT float -0.0 + %fcmp:_(s32) = G_FCMP floatpred(olt), %lhs(s32), %rhs + %select:_(s32) = G_SELECT %fcmp, %lhs, %rhs + $s0 = COPY %select + RET_ReallyLR implicit $s0