From aea3149e6c7ce0c3aafb6353f8547085b1ded297 Mon Sep 17 00:00:00 2001 From: Cameron McInally Date: Fri, 31 May 2019 15:10:34 +0000 Subject: [PATCH] [NFC][InstCombine] Add unary FNeg tests to fdiv.ll llvm-svn: 362231 --- llvm/test/Transforms/InstCombine/fdiv.ll | 118 +++++++++++++++++++++++++++++++ 1 file changed, 118 insertions(+) diff --git a/llvm/test/Transforms/InstCombine/fdiv.ll b/llvm/test/Transforms/InstCombine/fdiv.ll index 796eef9..619554e 100644 --- a/llvm/test/Transforms/InstCombine/fdiv.ll +++ b/llvm/test/Transforms/InstCombine/fdiv.ll @@ -198,6 +198,39 @@ define float @fneg_fneg(float %x, float %y) { ret float %div } +define float @unary_fneg_unary_fneg(float %x, float %y) { +; CHECK-LABEL: @unary_fneg_unary_fneg( +; CHECK-NEXT: [[DIV:%.*]] = fdiv float [[X:%.*]], [[Y:%.*]] +; CHECK-NEXT: ret float [[DIV]] +; + %x.fneg = fneg float %x + %y.fneg = fneg float %y + %div = fdiv float %x.fneg, %y.fneg + ret float %div +} + +define float @unary_fneg_fneg(float %x, float %y) { +; CHECK-LABEL: @unary_fneg_fneg( +; CHECK-NEXT: [[DIV:%.*]] = fdiv float [[X:%.*]], [[Y:%.*]] +; CHECK-NEXT: ret float [[DIV]] +; + %x.fneg = fneg float %x + %y.fneg = fsub float -0.0, %y + %div = fdiv float %x.fneg, %y.fneg + ret float %div +} + +define float @fneg_unary_fneg(float %x, float %y) { +; CHECK-LABEL: @fneg_unary_fneg( +; CHECK-NEXT: [[DIV:%.*]] = fdiv float [[X:%.*]], [[Y:%.*]] +; CHECK-NEXT: ret float [[DIV]] +; + %x.fneg = fsub float -0.0, %x + %y.fneg = fneg float %y + %div = fdiv float %x.fneg, %y.fneg + ret float %div +} + ; The test above shows that no FMF are needed, but show that we are not dropping FMF. define float @fneg_fneg_fast(float %x, float %y) { @@ -211,6 +244,17 @@ define float @fneg_fneg_fast(float %x, float %y) { ret float %div } +define float @unary_fneg_unary_fneg_fast(float %x, float %y) { +; CHECK-LABEL: @unary_fneg_unary_fneg_fast( +; CHECK-NEXT: [[DIV:%.*]] = fdiv fast float [[X:%.*]], [[Y:%.*]] +; CHECK-NEXT: ret float [[DIV]] +; + %x.fneg = fneg float %x + %y.fneg = fneg float %y + %div = fdiv fast float %x.fneg, %y.fneg + ret float %div +} + define <2 x float> @fneg_fneg_vec(<2 x float> %x, <2 x float> %y) { ; CHECK-LABEL: @fneg_fneg_vec( ; CHECK-NEXT: [[DIV:%.*]] = fdiv <2 x float> [[X:%.*]], [[Y:%.*]] @@ -222,6 +266,39 @@ define <2 x float> @fneg_fneg_vec(<2 x float> %x, <2 x float> %y) { ret <2 x float> %div } +define <2 x float> @unary_fneg_unary_fneg_vec(<2 x float> %x, <2 x float> %y) { +; CHECK-LABEL: @unary_fneg_unary_fneg_vec( +; CHECK-NEXT: [[DIV:%.*]] = fdiv <2 x float> [[X:%.*]], [[Y:%.*]] +; CHECK-NEXT: ret <2 x float> [[DIV]] +; + %xneg = fneg <2 x float> %x + %yneg = fneg <2 x float> %y + %div = fdiv <2 x float> %xneg, %yneg + ret <2 x float> %div +} + +define <2 x float> @fneg_unary_fneg_vec(<2 x float> %x, <2 x float> %y) { +; CHECK-LABEL: @fneg_unary_fneg_vec( +; CHECK-NEXT: [[DIV:%.*]] = fdiv <2 x float> [[X:%.*]], [[Y:%.*]] +; CHECK-NEXT: ret <2 x float> [[DIV]] +; + %xneg = fsub <2 x float> , %x + %yneg = fneg <2 x float> %y + %div = fdiv <2 x float> %xneg, %yneg + ret <2 x float> %div +} + +define <2 x float> @unary_fneg_fneg_vec(<2 x float> %x, <2 x float> %y) { +; CHECK-LABEL: @unary_fneg_fneg_vec( +; CHECK-NEXT: [[DIV:%.*]] = fdiv <2 x float> [[X:%.*]], [[Y:%.*]] +; CHECK-NEXT: ret <2 x float> [[DIV]] +; + %xneg = fneg <2 x float> %x + %yneg = fsub <2 x float> , %y + %div = fdiv <2 x float> %xneg, %yneg + ret <2 x float> %div +} + define <2 x float> @fneg_fneg_vec_undef_elts(<2 x float> %x, <2 x float> %y) { ; CHECK-LABEL: @fneg_fneg_vec_undef_elts( ; CHECK-NEXT: [[DIV:%.*]] = fdiv <2 x float> [[X:%.*]], [[Y:%.*]] @@ -243,6 +320,16 @@ define float @fneg_dividend_constant_divisor(float %x) { ret float %div } +define float @unary_fneg_dividend_constant_divisor(float %x) { +; CHECK-LABEL: @unary_fneg_dividend_constant_divisor( +; CHECK-NEXT: [[DIV:%.*]] = fdiv nsz float [[X:%.*]], -3.000000e+00 +; CHECK-NEXT: ret float [[DIV]] +; + %neg = fneg float %x + %div = fdiv nsz float %neg, 3.0 + ret float %div +} + define float @fneg_divisor_constant_dividend(float %x) { ; CHECK-LABEL: @fneg_divisor_constant_dividend( ; CHECK-NEXT: [[DIV:%.*]] = fdiv nnan float 3.000000e+00, [[X:%.*]] @@ -253,6 +340,16 @@ define float @fneg_divisor_constant_dividend(float %x) { ret float %div } +define float @unary_fneg_divisor_constant_dividend(float %x) { +; CHECK-LABEL: @unary_fneg_divisor_constant_dividend( +; CHECK-NEXT: [[DIV:%.*]] = fdiv nnan float 3.000000e+00, [[X:%.*]] +; CHECK-NEXT: ret float [[DIV]] +; + %neg = fneg float %x + %div = fdiv nnan float -3.0, %neg + ret float %div +} + define <2 x float> @fneg_dividend_constant_divisor_vec(<2 x float> %x) { ; CHECK-LABEL: @fneg_dividend_constant_divisor_vec( ; CHECK-NEXT: [[DIV:%.*]] = fdiv ninf <2 x float> [[X:%.*]], @@ -263,6 +360,16 @@ define <2 x float> @fneg_dividend_constant_divisor_vec(<2 x float> %x) { ret <2 x float> %div } +define <2 x float> @unary_fneg_dividend_constant_divisor_vec(<2 x float> %x) { +; CHECK-LABEL: @unary_fneg_dividend_constant_divisor_vec( +; CHECK-NEXT: [[DIV:%.*]] = fdiv ninf <2 x float> [[X:%.*]], +; CHECK-NEXT: ret <2 x float> [[DIV]] +; + %neg = fneg <2 x float> %x + %div = fdiv ninf <2 x float> %neg, + ret <2 x float> %div +} + define <2 x float> @fneg_dividend_constant_divisor_vec_undef_elt(<2 x float> %x) { ; CHECK-LABEL: @fneg_dividend_constant_divisor_vec_undef_elt( ; CHECK-NEXT: [[DIV:%.*]] = fdiv ninf <2 x float> [[X:%.*]], @@ -283,6 +390,17 @@ define <2 x float> @fneg_divisor_constant_dividend_vec(<2 x float> %x) { ret <2 x float> %div } +define <2 x float> @unary_fneg_divisor_constant_dividend_vec(<2 x float> %x) { +; CHECK-LABEL: @unary_fneg_divisor_constant_dividend_vec( +; CHECK-NEXT: [[DIV:%.*]] = fdiv afn <2 x float> , [[X:%.*]] +; CHECK-NEXT: ret <2 x float> [[DIV]] +; + %neg = fneg <2 x float> %x + %div = fdiv afn <2 x float> , %neg + ret <2 x float> %div +} + + ; X / (X * Y) --> 1.0 / Y define float @div_factor(float %x, float %y) { -- 2.7.4