diff --git a/llvm/lib/Transforms/InstCombine/InstCombineSelect.cpp b/llvm/lib/Transforms/InstCombine/InstCombineSelect.cpp --- a/llvm/lib/Transforms/InstCombine/InstCombineSelect.cpp +++ b/llvm/lib/Transforms/InstCombine/InstCombineSelect.cpp @@ -2344,12 +2344,12 @@ if (FCI->hasOneUse() && FCmpInst::isUnordered(FCI->getPredicate())) { FCmpInst::Predicate InvPred = FCI->getInversePredicate(); IRBuilder<>::FastMathFlagGuard FMFG(Builder); + // FIXME: The FMF should propagate from the select, not the fcmp. Builder.setFastMathFlags(FCI->getFastMathFlags()); Value *NewCond = Builder.CreateFCmp(InvPred, Cmp0, Cmp1, FCI->getName() + ".inv"); - - return SelectInst::Create(NewCond, FalseVal, TrueVal, - SI.getName() + ".p"); + Value *NewSel = Builder.CreateSelect(NewCond, FalseVal, TrueVal); + return replaceInstUsesWith(SI, NewSel); } // NOTE: if we wanted to, this is where to detect MIN/MAX diff --git a/llvm/test/Transforms/InstCombine/clamp-to-minmax.ll b/llvm/test/Transforms/InstCombine/clamp-to-minmax.ll --- a/llvm/test/Transforms/InstCombine/clamp-to-minmax.ll +++ b/llvm/test/Transforms/InstCombine/clamp-to-minmax.ll @@ -6,9 +6,8 @@ ; CHECK-LABEL: define {{[^@]+}}@clamp_float_fast_ordered_strict_maxmin( ; CHECK-NEXT: [[CMP2:%.*]] = fcmp fast olt float [[X:%.*]], 2.550000e+02 ; CHECK-NEXT: [[MIN:%.*]] = select i1 [[CMP2]], float [[X]], float 2.550000e+02 -; CHECK-NEXT: [[DOTINV:%.*]] = fcmp fast oge float [[MIN]], 1.000000e+00 -; CHECK-NEXT: [[R1:%.*]] = select i1 [[DOTINV]], float [[MIN]], float 1.000000e+00 -; CHECK-NEXT: ret float [[R1]] +; CHECK-NEXT: [[TMP1:%.*]] = call fast float @llvm.maxnum.f32(float [[MIN]], float 1.000000e+00) +; CHECK-NEXT: ret float [[TMP1]] ; %cmp2 = fcmp fast olt float %x, 255.0 %min = select i1 %cmp2, float %x, float 255.0 @@ -22,9 +21,8 @@ ; CHECK-LABEL: define {{[^@]+}}@clamp_float_fast_ordered_nonstrict_maxmin( ; CHECK-NEXT: [[CMP2:%.*]] = fcmp fast olt float [[X:%.*]], 2.550000e+02 ; CHECK-NEXT: [[MIN:%.*]] = select i1 [[CMP2]], float [[X]], float 2.550000e+02 -; CHECK-NEXT: [[DOTINV:%.*]] = fcmp fast oge float [[MIN]], 1.000000e+00 -; CHECK-NEXT: [[R1:%.*]] = select i1 [[DOTINV]], float [[MIN]], float 1.000000e+00 -; CHECK-NEXT: ret float [[R1]] +; CHECK-NEXT: [[TMP1:%.*]] = call fast float @llvm.maxnum.f32(float [[MIN]], float 1.000000e+00) +; CHECK-NEXT: ret float [[TMP1]] ; %cmp2 = fcmp fast olt float %x, 255.0 %min = select i1 %cmp2, float %x, float 255.0 @@ -38,9 +36,8 @@ ; CHECK-LABEL: define {{[^@]+}}@clamp_float_fast_ordered_strict_minmax( ; CHECK-NEXT: [[CMP2:%.*]] = fcmp fast ogt float [[X:%.*]], 1.000000e+00 ; CHECK-NEXT: [[MAX:%.*]] = select i1 [[CMP2]], float [[X]], float 1.000000e+00 -; CHECK-NEXT: [[DOTINV:%.*]] = fcmp fast ole float [[MAX]], 2.550000e+02 -; CHECK-NEXT: [[R1:%.*]] = select i1 [[DOTINV]], float [[MAX]], float 2.550000e+02 -; CHECK-NEXT: ret float [[R1]] +; CHECK-NEXT: [[TMP1:%.*]] = call fast float @llvm.minnum.f32(float [[MAX]], float 2.550000e+02) +; CHECK-NEXT: ret float [[TMP1]] ; %cmp2 = fcmp fast ogt float %x, 1.0 %max = select i1 %cmp2, float %x, float 1.0 @@ -54,9 +51,8 @@ ; CHECK-LABEL: define {{[^@]+}}@clamp_float_fast_ordered_nonstrict_minmax( ; CHECK-NEXT: [[CMP2:%.*]] = fcmp fast ogt float [[X:%.*]], 1.000000e+00 ; CHECK-NEXT: [[MAX:%.*]] = select i1 [[CMP2]], float [[X]], float 1.000000e+00 -; CHECK-NEXT: [[DOTINV:%.*]] = fcmp fast ole float [[MAX]], 2.550000e+02 -; CHECK-NEXT: [[R1:%.*]] = select i1 [[DOTINV]], float [[MAX]], float 2.550000e+02 -; CHECK-NEXT: ret float [[R1]] +; CHECK-NEXT: [[TMP1:%.*]] = call fast float @llvm.minnum.f32(float [[MAX]], float 2.550000e+02) +; CHECK-NEXT: ret float [[TMP1]] ; %cmp2 = fcmp fast ogt float %x, 1.0 %max = select i1 %cmp2, float %x, float 1.0 @@ -72,10 +68,9 @@ define float @clamp_float_fast_unordered_strict_maxmin(float %x) { ; CHECK-LABEL: define {{[^@]+}}@clamp_float_fast_unordered_strict_maxmin( ; CHECK-NEXT: [[CMP2_INV:%.*]] = fcmp fast oge float [[X:%.*]], 2.550000e+02 -; CHECK-NEXT: [[MIN:%.*]] = select i1 [[CMP2_INV]], float 2.550000e+02, float [[X]] -; CHECK-NEXT: [[DOTINV:%.*]] = fcmp fast oge float [[MIN]], 1.000000e+00 -; CHECK-NEXT: [[R1:%.*]] = select i1 [[DOTINV]], float [[MIN]], float 1.000000e+00 -; CHECK-NEXT: ret float [[R1]] +; CHECK-NEXT: [[TMP1:%.*]] = select fast i1 [[CMP2_INV]], float 2.550000e+02, float [[X]] +; CHECK-NEXT: [[TMP2:%.*]] = call fast float @llvm.maxnum.f32(float [[TMP1]], float 1.000000e+00) +; CHECK-NEXT: ret float [[TMP2]] ; %cmp2 = fcmp fast ult float %x, 255.0 %min = select i1 %cmp2, float %x, float 255.0 @@ -88,10 +83,9 @@ define float @clamp_float_fast_unordered_nonstrict_maxmin(float %x) { ; CHECK-LABEL: define {{[^@]+}}@clamp_float_fast_unordered_nonstrict_maxmin( ; CHECK-NEXT: [[CMP2_INV:%.*]] = fcmp fast oge float [[X:%.*]], 2.550000e+02 -; CHECK-NEXT: [[MIN:%.*]] = select i1 [[CMP2_INV]], float 2.550000e+02, float [[X]] -; CHECK-NEXT: [[DOTINV:%.*]] = fcmp fast oge float [[MIN]], 1.000000e+00 -; CHECK-NEXT: [[R1:%.*]] = select i1 [[DOTINV]], float [[MIN]], float 1.000000e+00 -; CHECK-NEXT: ret float [[R1]] +; CHECK-NEXT: [[TMP1:%.*]] = select fast i1 [[CMP2_INV]], float 2.550000e+02, float [[X]] +; CHECK-NEXT: [[TMP2:%.*]] = call fast float @llvm.maxnum.f32(float [[TMP1]], float 1.000000e+00) +; CHECK-NEXT: ret float [[TMP2]] ; %cmp2 = fcmp fast ult float %x, 255.0 %min = select i1 %cmp2, float %x, float 255.0 @@ -104,10 +98,9 @@ define float @clamp_float_fast_unordered_strict_minmax(float %x) { ; CHECK-LABEL: define {{[^@]+}}@clamp_float_fast_unordered_strict_minmax( ; CHECK-NEXT: [[CMP2_INV:%.*]] = fcmp fast ole float [[X:%.*]], 1.000000e+00 -; CHECK-NEXT: [[MAX:%.*]] = select i1 [[CMP2_INV]], float 1.000000e+00, float [[X]] -; CHECK-NEXT: [[DOTINV:%.*]] = fcmp fast ole float [[MAX]], 2.550000e+02 -; CHECK-NEXT: [[R1:%.*]] = select i1 [[DOTINV]], float [[MAX]], float 2.550000e+02 -; CHECK-NEXT: ret float [[R1]] +; CHECK-NEXT: [[TMP1:%.*]] = select fast i1 [[CMP2_INV]], float 1.000000e+00, float [[X]] +; CHECK-NEXT: [[TMP2:%.*]] = call fast float @llvm.minnum.f32(float [[TMP1]], float 2.550000e+02) +; CHECK-NEXT: ret float [[TMP2]] ; %cmp2 = fcmp fast ugt float %x, 1.0 %max = select i1 %cmp2, float %x, float 1.0 @@ -120,10 +113,9 @@ define float @clamp_float_fast_unordered_nonstrict_minmax(float %x) { ; CHECK-LABEL: define {{[^@]+}}@clamp_float_fast_unordered_nonstrict_minmax( ; CHECK-NEXT: [[CMP2_INV:%.*]] = fcmp fast ole float [[X:%.*]], 1.000000e+00 -; CHECK-NEXT: [[MAX:%.*]] = select i1 [[CMP2_INV]], float 1.000000e+00, float [[X]] -; CHECK-NEXT: [[DOTINV:%.*]] = fcmp fast ole float [[MAX]], 2.550000e+02 -; CHECK-NEXT: [[R1:%.*]] = select i1 [[DOTINV]], float [[MAX]], float 2.550000e+02 -; CHECK-NEXT: ret float [[R1]] +; CHECK-NEXT: [[TMP1:%.*]] = select fast i1 [[CMP2_INV]], float 1.000000e+00, float [[X]] +; CHECK-NEXT: [[TMP2:%.*]] = call fast float @llvm.minnum.f32(float [[TMP1]], float 2.550000e+02) +; CHECK-NEXT: ret float [[TMP2]] ; %cmp2 = fcmp fast ugt float %x, 1.0 %max = select i1 %cmp2, float %x, float 1.0 @@ -139,10 +131,9 @@ define float @clamp_test_1(float %x) { ; CHECK-LABEL: define {{[^@]+}}@clamp_test_1( ; CHECK-NEXT: [[INNER_CMP_INV:%.*]] = fcmp fast oge float [[X:%.*]], 2.550000e+02 -; CHECK-NEXT: [[INNER_SEL:%.*]] = select i1 [[INNER_CMP_INV]], float 2.550000e+02, float [[X]] -; CHECK-NEXT: [[DOTINV:%.*]] = fcmp fast oge float [[INNER_SEL]], 1.000000e+00 -; CHECK-NEXT: [[R1:%.*]] = select i1 [[DOTINV]], float [[INNER_SEL]], float 1.000000e+00 -; CHECK-NEXT: ret float [[R1]] +; CHECK-NEXT: [[TMP1:%.*]] = select fast i1 [[INNER_CMP_INV]], float 2.550000e+02, float [[X]] +; CHECK-NEXT: [[TMP2:%.*]] = call fast float @llvm.maxnum.f32(float [[TMP1]], float 1.000000e+00) +; CHECK-NEXT: ret float [[TMP2]] ; %inner_cmp = fcmp fast ult float %x, 255.0 %inner_sel = select i1 %inner_cmp, float %x, float 255.0 @@ -157,9 +148,9 @@ define float @clamp_negative_wrong_const(float %x) { ; CHECK-LABEL: define {{[^@]+}}@clamp_negative_wrong_const( ; CHECK-NEXT: [[INNER_CMP_INV:%.*]] = fcmp fast oge float [[X:%.*]], 2.550000e+02 -; CHECK-NEXT: [[INNER_SEL:%.*]] = select i1 [[INNER_CMP_INV]], float 2.550000e+02, float [[X]] +; CHECK-NEXT: [[TMP1:%.*]] = select fast i1 [[INNER_CMP_INV]], float 2.550000e+02, float [[X]] ; CHECK-NEXT: [[OUTER_CMP:%.*]] = fcmp fast ugt float [[X]], 5.120000e+02 -; CHECK-NEXT: [[R:%.*]] = select i1 [[OUTER_CMP]], float [[INNER_SEL]], float 5.120000e+02 +; CHECK-NEXT: [[R:%.*]] = select i1 [[OUTER_CMP]], float [[TMP1]], float 5.120000e+02 ; CHECK-NEXT: ret float [[R]] ; %inner_cmp = fcmp fast ult float %x, 255.0 @@ -173,9 +164,9 @@ define float @clamp_negative_same_op(float %x) { ; CHECK-LABEL: define {{[^@]+}}@clamp_negative_same_op( ; CHECK-NEXT: [[INNER_CMP_INV:%.*]] = fcmp fast oge float [[X:%.*]], 2.550000e+02 -; CHECK-NEXT: [[INNER_SEL:%.*]] = select i1 [[INNER_CMP_INV]], float 2.550000e+02, float [[X]] +; CHECK-NEXT: [[TMP1:%.*]] = select fast i1 [[INNER_CMP_INV]], float 2.550000e+02, float [[X]] ; CHECK-NEXT: [[OUTER_CMP:%.*]] = fcmp fast ult float [[X]], 1.000000e+00 -; CHECK-NEXT: [[R:%.*]] = select i1 [[OUTER_CMP]], float [[INNER_SEL]], float 1.000000e+00 +; CHECK-NEXT: [[R:%.*]] = select i1 [[OUTER_CMP]], float [[TMP1]], float 1.000000e+00 ; CHECK-NEXT: ret float [[R]] ; %inner_cmp = fcmp fast ult float %x, 255.0 diff --git a/llvm/test/Transforms/InstCombine/minmax-fold.ll b/llvm/test/Transforms/InstCombine/minmax-fold.ll --- a/llvm/test/Transforms/InstCombine/minmax-fold.ll +++ b/llvm/test/Transforms/InstCombine/minmax-fold.ll @@ -922,11 +922,11 @@ define float @not_min_of_min(i8 %i, float %x) { ; CHECK-LABEL: define {{[^@]+}}@not_min_of_min( ; CHECK-NEXT: [[CMP1_INV:%.*]] = fcmp fast oge float [[X:%.*]], 1.000000e+00 -; CHECK-NEXT: [[MIN1:%.*]] = select i1 [[CMP1_INV]], float 1.000000e+00, float [[X]] +; CHECK-NEXT: [[TMP1:%.*]] = select fast i1 [[CMP1_INV]], float 1.000000e+00, float [[X]] ; CHECK-NEXT: [[CMP2_INV:%.*]] = fcmp fast oge float [[X]], 2.000000e+00 -; CHECK-NEXT: [[MIN2:%.*]] = select i1 [[CMP2_INV]], float 2.000000e+00, float [[X]] +; CHECK-NEXT: [[TMP2:%.*]] = select fast i1 [[CMP2_INV]], float 2.000000e+00, float [[X]] ; CHECK-NEXT: [[CMP3:%.*]] = icmp ult i8 [[I:%.*]], 16 -; CHECK-NEXT: [[R:%.*]] = select i1 [[CMP3]], float [[MIN1]], float [[MIN2]] +; CHECK-NEXT: [[R:%.*]] = select i1 [[CMP3]], float [[TMP1]], float [[TMP2]] ; CHECK-NEXT: ret float [[R]] ; %cmp1 = fcmp fast ult float %x, 1.0 diff --git a/llvm/test/Transforms/InstCombine/minmax-fp.ll b/llvm/test/Transforms/InstCombine/minmax-fp.ll --- a/llvm/test/Transforms/InstCombine/minmax-fp.ll +++ b/llvm/test/Transforms/InstCombine/minmax-fp.ll @@ -149,9 +149,9 @@ define i8 @t11(float %a, float %b) { ; CHECK-LABEL: define {{[^@]+}}@t11( ; CHECK-NEXT: [[DOTINV:%.*]] = fcmp fast oge float [[B:%.*]], [[A:%.*]] -; CHECK-NEXT: [[DOTV:%.*]] = select i1 [[DOTINV]], float [[A]], float [[B]] -; CHECK-NEXT: [[TMP1:%.*]] = fptosi float [[DOTV]] to i8 -; CHECK-NEXT: ret i8 [[TMP1]] +; CHECK-NEXT: [[TMP1:%.*]] = select fast i1 [[DOTINV]], float [[A]], float [[B]] +; CHECK-NEXT: [[TMP2:%.*]] = fptosi float [[TMP1]] to i8 +; CHECK-NEXT: ret i8 [[TMP2]] ; %1 = fcmp fast ult float %b, %a %2 = fptosi float %a to i8 @@ -164,9 +164,9 @@ define i8 @t12(float %a, float %b) { ; CHECK-LABEL: define {{[^@]+}}@t12( ; CHECK-NEXT: [[DOTINV:%.*]] = fcmp nnan oge float [[B:%.*]], [[A:%.*]] -; CHECK-NEXT: [[DOTV:%.*]] = select i1 [[DOTINV]], float [[A]], float [[B]] -; CHECK-NEXT: [[TMP1:%.*]] = fptosi float [[DOTV]] to i8 -; CHECK-NEXT: ret i8 [[TMP1]] +; CHECK-NEXT: [[TMP1:%.*]] = select nnan i1 [[DOTINV]], float [[A]], float [[B]] +; CHECK-NEXT: [[TMP2:%.*]] = fptosi float [[TMP1]] to i8 +; CHECK-NEXT: ret i8 [[TMP2]] ; %1 = fcmp nnan ult float %b, %a %2 = fptosi float %a to i8 @@ -219,7 +219,7 @@ define i8 @t15(float %a) { ; CHECK-LABEL: define {{[^@]+}}@t15( ; CHECK-NEXT: [[DOTINV:%.*]] = fcmp nsz oge float [[A:%.*]], 0.000000e+00 -; CHECK-NEXT: [[TMP1:%.*]] = select i1 [[DOTINV]], float 0.000000e+00, float [[A]] +; CHECK-NEXT: [[TMP1:%.*]] = select nsz i1 [[DOTINV]], float 0.000000e+00, float [[A]] ; CHECK-NEXT: [[TMP2:%.*]] = fptosi float [[TMP1]] to i8 ; CHECK-NEXT: ret i8 [[TMP2]] ; @@ -272,8 +272,8 @@ define <2 x float> @fsub_fmax(<2 x float> %x, <2 x float> %y) { ; CHECK-LABEL: define {{[^@]+}}@fsub_fmax( ; CHECK-NEXT: [[COND_INV:%.*]] = fcmp nnan nsz ogt <2 x float> [[X:%.*]], [[Y:%.*]] -; CHECK-NEXT: [[MAX_V:%.*]] = select <2 x i1> [[COND_INV]], <2 x float> [[Y]], <2 x float> [[X]] -; CHECK-NEXT: [[MAX:%.*]] = fsub <2 x float> , [[MAX_V]] +; CHECK-NEXT: [[TMP1:%.*]] = select nnan nsz <2 x i1> [[COND_INV]], <2 x float> [[Y]], <2 x float> [[X]] +; CHECK-NEXT: [[MAX:%.*]] = fsub <2 x float> , [[TMP1]] ; CHECK-NEXT: ret <2 x float> [[MAX]] ; %n1 = fsub <2 x float> , %x @@ -300,8 +300,8 @@ define double @fneg_fmin(double %x, double %y) { ; CHECK-LABEL: define {{[^@]+}}@fneg_fmin( ; CHECK-NEXT: [[COND_INV:%.*]] = fcmp nnan nsz olt double [[X:%.*]], [[Y:%.*]] -; CHECK-NEXT: [[MAX_V:%.*]] = select i1 [[COND_INV]], double [[Y]], double [[X]] -; CHECK-NEXT: [[MAX:%.*]] = fneg double [[MAX_V]] +; CHECK-NEXT: [[TMP1:%.*]] = select nnan nsz i1 [[COND_INV]], double [[Y]], double [[X]] +; CHECK-NEXT: [[MAX:%.*]] = fneg double [[TMP1]] ; CHECK-NEXT: ret double [[MAX]] ; %n1 = fneg double %x diff --git a/llvm/test/Transforms/InstCombine/unordered-fcmp-select.ll b/llvm/test/Transforms/InstCombine/unordered-fcmp-select.ll --- a/llvm/test/Transforms/InstCombine/unordered-fcmp-select.ll +++ b/llvm/test/Transforms/InstCombine/unordered-fcmp-select.ll @@ -4,8 +4,8 @@ define float @select_max_ugt(float %a, float %b) { ; CHECK-LABEL: define {{[^@]+}}@select_max_ugt( ; CHECK-NEXT: [[CMP_INV:%.*]] = fcmp arcp ole float [[A:%.*]], [[B:%.*]] -; CHECK-NEXT: [[SEL:%.*]] = select i1 [[CMP_INV]], float [[B]], float [[A]] -; CHECK-NEXT: ret float [[SEL]] +; CHECK-NEXT: [[TMP1:%.*]] = select arcp i1 [[CMP_INV]], float [[B]], float [[A]] +; CHECK-NEXT: ret float [[TMP1]] ; %cmp = fcmp arcp ugt float %a, %b %sel = select arcp i1 %cmp, float %a, float %b @@ -15,8 +15,8 @@ define float @select_max_uge(float %a, float %b) { ; CHECK-LABEL: define {{[^@]+}}@select_max_uge( ; CHECK-NEXT: [[CMP_INV:%.*]] = fcmp nnan olt float [[A:%.*]], [[B:%.*]] -; CHECK-NEXT: [[SEL:%.*]] = select i1 [[CMP_INV]], float [[B]], float [[A]] -; CHECK-NEXT: ret float [[SEL]] +; CHECK-NEXT: [[TMP1:%.*]] = select nnan i1 [[CMP_INV]], float [[B]], float [[A]] +; CHECK-NEXT: ret float [[TMP1]] ; %cmp = fcmp nnan uge float %a, %b %sel = select ninf i1 %cmp, float %a, float %b @@ -25,9 +25,8 @@ define float @select_min_ugt(float %a, float %b) { ; CHECK-LABEL: define {{[^@]+}}@select_min_ugt( -; CHECK-NEXT: [[CMP_INV:%.*]] = fcmp fast ole float [[A:%.*]], [[B:%.*]] -; CHECK-NEXT: [[SEL:%.*]] = select i1 [[CMP_INV]], float [[A]], float [[B]] -; CHECK-NEXT: ret float [[SEL]] +; CHECK-NEXT: [[TMP1:%.*]] = call fast float @llvm.minnum.f32(float [[A:%.*]], float [[B:%.*]]) +; CHECK-NEXT: ret float [[TMP1]] ; %cmp = fcmp fast ugt float %a, %b %sel = select reassoc i1 %cmp, float %b, float %a @@ -37,8 +36,8 @@ define float @select_min_uge(float %a, float %b) { ; CHECK-LABEL: define {{[^@]+}}@select_min_uge( ; CHECK-NEXT: [[CMP_INV:%.*]] = fcmp nsz olt float [[A:%.*]], [[B:%.*]] -; CHECK-NEXT: [[SEL:%.*]] = select i1 [[CMP_INV]], float [[A]], float [[B]] -; CHECK-NEXT: ret float [[SEL]] +; CHECK-NEXT: [[TMP1:%.*]] = select nsz i1 [[CMP_INV]], float [[A]], float [[B]] +; CHECK-NEXT: ret float [[TMP1]] ; %cmp = fcmp nsz uge float %a, %b %sel = select fast i1 %cmp, float %b, float %a @@ -48,8 +47,8 @@ define float @select_max_ult(float %a, float %b) { ; CHECK-LABEL: define {{[^@]+}}@select_max_ult( ; CHECK-NEXT: [[CMP_INV:%.*]] = fcmp arcp oge float [[A:%.*]], [[B:%.*]] -; CHECK-NEXT: [[SEL:%.*]] = select i1 [[CMP_INV]], float [[A]], float [[B]] -; CHECK-NEXT: ret float [[SEL]] +; CHECK-NEXT: [[TMP1:%.*]] = select arcp i1 [[CMP_INV]], float [[A]], float [[B]] +; CHECK-NEXT: ret float [[TMP1]] ; %cmp = fcmp arcp ult float %a, %b %sel = select ninf nnan i1 %cmp, float %b, float %a @@ -58,9 +57,8 @@ define float @select_max_ule(float %a, float %b) { ; CHECK-LABEL: define {{[^@]+}}@select_max_ule( -; CHECK-NEXT: [[CMP_INV:%.*]] = fcmp fast ogt float [[A:%.*]], [[B:%.*]] -; CHECK-NEXT: [[SEL:%.*]] = select i1 [[CMP_INV]], float [[A]], float [[B]] -; CHECK-NEXT: ret float [[SEL]] +; CHECK-NEXT: [[TMP1:%.*]] = call fast float @llvm.maxnum.f32(float [[A:%.*]], float [[B:%.*]]) +; CHECK-NEXT: ret float [[TMP1]] ; %cmp = fcmp fast ule float %a, %b %sel = select nsz i1 %cmp, float %b, float %a @@ -70,8 +68,8 @@ define float @select_min_ult(float %a, float %b) { ; CHECK-LABEL: define {{[^@]+}}@select_min_ult( ; CHECK-NEXT: [[CMP_INV:%.*]] = fcmp nsz oge float [[A:%.*]], [[B:%.*]] -; CHECK-NEXT: [[SEL:%.*]] = select i1 [[CMP_INV]], float [[B]], float [[A]] -; CHECK-NEXT: ret float [[SEL]] +; CHECK-NEXT: [[TMP1:%.*]] = select nsz i1 [[CMP_INV]], float [[B]], float [[A]] +; CHECK-NEXT: ret float [[TMP1]] ; %cmp = fcmp nsz ult float %a, %b %sel = select fast i1 %cmp, float %a, float %b @@ -81,8 +79,8 @@ define float @select_min_ule(float %a, float %b) { ; CHECK-LABEL: define {{[^@]+}}@select_min_ule( ; CHECK-NEXT: [[CMP_INV:%.*]] = fcmp arcp ogt float [[A:%.*]], [[B:%.*]] -; CHECK-NEXT: [[SEL:%.*]] = select i1 [[CMP_INV]], float [[B]], float [[A]] -; CHECK-NEXT: ret float [[SEL]] +; CHECK-NEXT: [[TMP1:%.*]] = select arcp i1 [[CMP_INV]], float [[B]], float [[A]] +; CHECK-NEXT: ret float [[TMP1]] ; %cmp = fcmp arcp ule float %a, %b %sel = select ninf i1 %cmp, float %a, float %b @@ -92,8 +90,8 @@ define float @select_fcmp_une(float %a, float %b) { ; CHECK-LABEL: define {{[^@]+}}@select_fcmp_une( ; CHECK-NEXT: [[CMP_INV:%.*]] = fcmp reassoc oeq float [[A:%.*]], [[B:%.*]] -; CHECK-NEXT: [[SEL:%.*]] = select i1 [[CMP_INV]], float [[B]], float [[A]] -; CHECK-NEXT: ret float [[SEL]] +; CHECK-NEXT: [[TMP1:%.*]] = select reassoc i1 [[CMP_INV]], float [[B]], float [[A]] +; CHECK-NEXT: ret float [[TMP1]] ; %cmp = fcmp reassoc une float %a, %b %sel = select nnan i1 %cmp, float %a, float %b @@ -103,8 +101,8 @@ define float @select_fcmp_ueq(float %a, float %b) { ; CHECK-LABEL: define {{[^@]+}}@select_fcmp_ueq( ; CHECK-NEXT: [[CMP_INV:%.*]] = fcmp reassoc one float [[A:%.*]], [[B:%.*]] -; CHECK-NEXT: [[SEL:%.*]] = select i1 [[CMP_INV]], float [[B]], float [[A]] -; CHECK-NEXT: ret float [[SEL]] +; CHECK-NEXT: [[TMP1:%.*]] = select reassoc i1 [[CMP_INV]], float [[B]], float [[A]] +; CHECK-NEXT: ret float [[TMP1]] ; %cmp = fcmp reassoc ueq float %a, %b %sel = select arcp nnan i1 %cmp, float %a, float %b