From bebc7d6a4e5dc0531f51dc98a085d1a9170351b3 Mon Sep 17 00:00:00 2001 From: Cameron McInally Date: Fri, 17 May 2019 18:34:35 +0000 Subject: [PATCH] [NFC][InstSimplify] Precommit new unary fneg test llvm-svn: 361060 --- .../InstSimplify/floating-point-arithmetic.ll | 34 +++++++++++++++++++ .../InstSimplify/known-never-nan.ll | 17 ++++++++-- 2 files changed, 49 insertions(+), 2 deletions(-) diff --git a/llvm/test/Transforms/InstSimplify/floating-point-arithmetic.ll b/llvm/test/Transforms/InstSimplify/floating-point-arithmetic.ll index 868c4a207351..b24293cead4f 100644 --- a/llvm/test/Transforms/InstSimplify/floating-point-arithmetic.ll +++ b/llvm/test/Transforms/InstSimplify/floating-point-arithmetic.ll @@ -28,6 +28,18 @@ define float @fsub_-0_-0_x(float %a) { ret float %ret } +; fsub -0.0, (fneg X) ==> X +define float @fneg_x(float %a) { +; CHECK-LABEL: @fneg_x( +; CHECK-NEXT: %t1 = fneg float %a +; CHECK-NEXT: %ret = fsub float -0.000000e+00, %t1 +; CHECK-NEXT: ret float %ret +; + %t1 = fneg float %a + %ret = fsub float -0.0, %t1 + ret float %ret +} + define <2 x float> @fsub_-0_-0_x_vec(<2 x float> %a) { ; CHECK-LABEL: @fsub_-0_-0_x_vec( ; CHECK-NEXT: ret <2 x float> [[A:%.*]] @@ -37,6 +49,17 @@ define <2 x float> @fsub_-0_-0_x_vec(<2 x float> %a) { ret <2 x float> %ret } +define <2 x float> @fneg_x_vec(<2 x float> %a) { +; CHECK-LABEL: @fneg_x_vec( +; CHECK-NEXT: %t1 = fneg <2 x float> %a +; CHECK-NEXT: %ret = fsub <2 x float> , %t1 +; CHECK-NEXT: ret <2 x float> %ret +; + %t1 = fneg <2 x float> %a + %ret = fsub <2 x float> , %t1 + ret <2 x float> %ret +} + define <2 x float> @fsub_-0_-0_x_vec_undef_elts(<2 x float> %a) { ; CHECK-LABEL: @fsub_-0_-0_x_vec_undef_elts( ; CHECK-NEXT: ret <2 x float> [[A:%.*]] @@ -46,6 +69,17 @@ define <2 x float> @fsub_-0_-0_x_vec_undef_elts(<2 x float> %a) { ret <2 x float> %ret } +define <2 x float> @fneg_x_vec_undef_elts(<2 x float> %a) { +; CHECK-LABEL: @fneg_x_vec_undef_elts( +; CHECK-NEXT: %t1 = fneg <2 x float> %a +; CHECK-NEXT: %ret = fsub <2 x float> , %t1 +; CHECK-NEXT: ret <2 x float> %ret +; + %t1 = fneg <2 x float> %a + %ret = fsub <2 x float> , %t1 + ret <2 x float> %ret +} + ; fsub -0.0, (fsub 0.0, X) != X define float @fsub_-0_0_x(float %a) { ; CHECK-LABEL: @fsub_-0_0_x( diff --git a/llvm/test/Transforms/InstSimplify/known-never-nan.ll b/llvm/test/Transforms/InstSimplify/known-never-nan.ll index d7c2fdc1cb1e..37cfc932aa43 100644 --- a/llvm/test/Transforms/InstSimplify/known-never-nan.ll +++ b/llvm/test/Transforms/InstSimplify/known-never-nan.ll @@ -255,8 +255,8 @@ define i1 @nnan_fsub(double %arg0, double %arg1) { ret i1 %tmp } -define i1 @nnan_fneg() { -; CHECK-LABEL: @nnan_fneg( +define i1 @nnan_binary_fneg() { +; CHECK-LABEL: @nnan_binary_fneg( ; CHECK-NEXT: [[NNAN:%.*]] = call nnan double @func() ; CHECK-NEXT: [[OP:%.*]] = fsub double -0.000000e+00, [[NNAN]] ; CHECK-NEXT: [[TMP:%.*]] = fcmp ord double [[OP]], [[OP]] @@ -268,6 +268,19 @@ define i1 @nnan_fneg() { ret i1 %tmp } +define i1 @nnan_unary_fneg() { +; CHECK-LABEL: @nnan_unary_fneg( +; CHECK-NEXT: [[NNAN:%.*]] = call nnan double @func() +; CHECK-NEXT: [[OP:%.*]] = fneg double [[NNAN]] +; CHECK-NEXT: [[TMP:%.*]] = fcmp ord double [[OP]], [[OP]] +; CHECK-NEXT: ret i1 [[TMP]] +; + %nnan = call nnan double @func() + %op = fneg double %nnan + %tmp = fcmp ord double %op, %op + ret i1 %tmp +} + define i1 @sitofp(i32 %arg0) { ; CHECK-LABEL: @sitofp( ; CHECK-NEXT: ret i1 false