From 6d2a4712f3accd3fa34ed2bdecdf2ebf987dccca Mon Sep 17 00:00:00 2001 From: Cameron McInally Date: Fri, 31 May 2019 15:40:03 +0000 Subject: [PATCH] [NFC][InstCombine] Add unary FNeg tests to fcmp.ll llvm-svn: 362234 --- llvm/test/Transforms/InstCombine/fcmp.ll | 118 +++++++++++++++++++++++ 1 file changed, 118 insertions(+) diff --git a/llvm/test/Transforms/InstCombine/fcmp.ll b/llvm/test/Transforms/InstCombine/fcmp.ll index be7aedc7c60f..cd941fea90e1 100644 --- a/llvm/test/Transforms/InstCombine/fcmp.ll +++ b/llvm/test/Transforms/InstCombine/fcmp.ll @@ -68,6 +68,16 @@ define i1 @fneg_constant_swap_pred(float %x) { ret i1 %cmp } +define i1 @unary_fneg_constant_swap_pred(float %x) { +; CHECK-LABEL: @unary_fneg_constant_swap_pred( +; CHECK-NEXT: [[CMP:%.*]] = fcmp olt float [[X:%.*]], -1.000000e+00 +; CHECK-NEXT: ret i1 [[CMP]] +; + %neg = fneg float %x + %cmp = fcmp ogt float %neg, 1.0 + ret i1 %cmp +} + define <2 x i1> @fneg_constant_swap_pred_vec(<2 x float> %x) { ; CHECK-LABEL: @fneg_constant_swap_pred_vec( ; CHECK-NEXT: [[CMP:%.*]] = fcmp olt <2 x float> [[X:%.*]], @@ -78,6 +88,16 @@ define <2 x i1> @fneg_constant_swap_pred_vec(<2 x float> %x) { ret <2 x i1> %cmp } +define <2 x i1> @unary_fneg_constant_swap_pred_vec(<2 x float> %x) { +; CHECK-LABEL: @unary_fneg_constant_swap_pred_vec( +; CHECK-NEXT: [[CMP:%.*]] = fcmp olt <2 x float> [[X:%.*]], +; CHECK-NEXT: ret <2 x i1> [[CMP]] +; + %neg = fneg <2 x float> %x + %cmp = fcmp ogt <2 x float> %neg, + ret <2 x i1> %cmp +} + define <2 x i1> @fneg_constant_swap_pred_vec_undef(<2 x float> %x) { ; CHECK-LABEL: @fneg_constant_swap_pred_vec_undef( ; CHECK-NEXT: [[CMP:%.*]] = fcmp olt <2 x float> [[X:%.*]], @@ -100,6 +120,16 @@ define i1 @fneg_fmf(float %x) { ret i1 %r } +define i1 @unary_fneg_fmf(float %x) { +; CHECK-LABEL: @unary_fneg_fmf( +; CHECK-NEXT: [[R:%.*]] = fcmp fast oeq float [[X:%.*]], -4.200000e+01 +; CHECK-NEXT: ret i1 [[R]] +; + %n = fneg fast float %x + %r = fcmp fast oeq float %n, 42.0 + ret i1 %r +} + ; The new fcmp should have the same FMF as the original, vector edition. define <2 x i1> @fcmp_fneg_fmf_vec(<2 x float> %x) { @@ -123,6 +153,39 @@ define i1 @fneg_fneg_swap_pred(float %x, float %y) { ret i1 %cmp } +define i1 @unary_fneg_unary_fneg_swap_pred(float %x, float %y) { +; CHECK-LABEL: @unary_fneg_unary_fneg_swap_pred( +; CHECK-NEXT: [[CMP:%.*]] = fcmp nnan ogt float [[X:%.*]], [[Y:%.*]] +; CHECK-NEXT: ret i1 [[CMP]] +; + %neg1 = fneg float %x + %neg2 = fneg float %y + %cmp = fcmp nnan olt float %neg1, %neg2 + ret i1 %cmp +} + +define i1 @unary_fneg_fneg_swap_pred(float %x, float %y) { +; CHECK-LABEL: @unary_fneg_fneg_swap_pred( +; CHECK-NEXT: [[CMP:%.*]] = fcmp nnan ogt float [[X:%.*]], [[Y:%.*]] +; CHECK-NEXT: ret i1 [[CMP]] +; + %neg1 = fneg float %x + %neg2 = fsub float -0.0, %y + %cmp = fcmp nnan olt float %neg1, %neg2 + ret i1 %cmp +} + +define i1 @fneg_unary_fneg_swap_pred(float %x, float %y) { +; CHECK-LABEL: @fneg_unary_fneg_swap_pred( +; CHECK-NEXT: [[CMP:%.*]] = fcmp nnan ogt float [[X:%.*]], [[Y:%.*]] +; CHECK-NEXT: ret i1 [[CMP]] +; + %neg1 = fsub float -0.0, %x + %neg2 = fneg float %y + %cmp = fcmp nnan olt float %neg1, %neg2 + ret i1 %cmp +} + define <2 x i1> @fneg_fneg_swap_pred_vec(<2 x float> %x, <2 x float> %y) { ; CHECK-LABEL: @fneg_fneg_swap_pred_vec( ; CHECK-NEXT: [[CMP:%.*]] = fcmp ninf ogt <2 x float> [[X:%.*]], [[Y:%.*]] @@ -134,6 +197,39 @@ define <2 x i1> @fneg_fneg_swap_pred_vec(<2 x float> %x, <2 x float> %y) { ret <2 x i1> %cmp } +define <2 x i1> @unary_fneg_unary_fneg_swap_pred_vec(<2 x float> %x, <2 x float> %y) { +; CHECK-LABEL: @unary_fneg_unary_fneg_swap_pred_vec( +; CHECK-NEXT: [[CMP:%.*]] = fcmp ninf ogt <2 x float> [[X:%.*]], [[Y:%.*]] +; CHECK-NEXT: ret <2 x i1> [[CMP]] +; + %neg1 = fneg <2 x float> %x + %neg2 = fneg <2 x float> %y + %cmp = fcmp ninf olt <2 x float> %neg1, %neg2 + ret <2 x i1> %cmp +} + +define <2 x i1> @unary_fneg_fneg_swap_pred_vec(<2 x float> %x, <2 x float> %y) { +; CHECK-LABEL: @unary_fneg_fneg_swap_pred_vec( +; CHECK-NEXT: [[CMP:%.*]] = fcmp ninf ogt <2 x float> [[X:%.*]], [[Y:%.*]] +; CHECK-NEXT: ret <2 x i1> [[CMP]] +; + %neg1 = fneg <2 x float> %x + %neg2 = fsub <2 x float> , %y + %cmp = fcmp ninf olt <2 x float> %neg1, %neg2 + ret <2 x i1> %cmp +} + +define <2 x i1> @fneg_unary_fneg_swap_pred_vec(<2 x float> %x, <2 x float> %y) { +; CHECK-LABEL: @fneg_unary_fneg_swap_pred_vec( +; CHECK-NEXT: [[CMP:%.*]] = fcmp ninf ogt <2 x float> [[X:%.*]], [[Y:%.*]] +; CHECK-NEXT: ret <2 x i1> [[CMP]] +; + %neg1 = fsub <2 x float> , %x + %neg2 = fneg <2 x float> %y + %cmp = fcmp ninf olt <2 x float> %neg1, %neg2 + ret <2 x i1> %cmp +} + define <2 x i1> @fneg_fneg_swap_pred_vec_undef(<2 x float> %x, <2 x float> %y) { ; CHECK-LABEL: @fneg_fneg_swap_pred_vec_undef( ; CHECK-NEXT: [[CMP:%.*]] = fcmp ogt <2 x float> [[X:%.*]], [[Y:%.*]] @@ -145,6 +241,28 @@ define <2 x i1> @fneg_fneg_swap_pred_vec_undef(<2 x float> %x, <2 x float> %y) { ret <2 x i1> %cmp } +define <2 x i1> @unary_fneg_fneg_swap_pred_vec_undef(<2 x float> %x, <2 x float> %y) { +; CHECK-LABEL: @unary_fneg_fneg_swap_pred_vec_undef( +; CHECK-NEXT: [[CMP:%.*]] = fcmp ogt <2 x float> [[X:%.*]], [[Y:%.*]] +; CHECK-NEXT: ret <2 x i1> [[CMP]] +; + %neg1 = fneg <2 x float> %x + %neg2 = fsub <2 x float> , %y + %cmp = fcmp olt <2 x float> %neg1, %neg2 + ret <2 x i1> %cmp +} + +define <2 x i1> @fneg_unary_fneg_swap_pred_vec_undef(<2 x float> %x, <2 x float> %y) { +; CHECK-LABEL: @fneg_unary_fneg_swap_pred_vec_undef( +; CHECK-NEXT: [[CMP:%.*]] = fcmp ogt <2 x float> [[X:%.*]], [[Y:%.*]] +; CHECK-NEXT: ret <2 x i1> [[CMP]] +; + %neg1 = fsub <2 x float> , %x + %neg2 = fneg <2 x float> %y + %cmp = fcmp olt <2 x float> %neg1, %neg2 + ret <2 x i1> %cmp +} + define i1 @test7(float %x) { ; CHECK-LABEL: @test7( ; CHECK-NEXT: [[CMP:%.*]] = fcmp ogt float [[X:%.*]], 0.000000e+00