[llvm] r362231 - [NFC][InstCombine] Add unary FNeg tests to fdiv.ll

Cameron McInally via llvm-commits llvm-commits at lists.llvm.org
Fri May 31 08:10:34 PDT 2019


Author: mcinally
Date: Fri May 31 08:10:34 2019
New Revision: 362231

URL: http://llvm.org/viewvc/llvm-project?rev=362231&view=rev
Log:
[NFC][InstCombine] Add unary FNeg tests to fdiv.ll

Modified:
    llvm/trunk/test/Transforms/InstCombine/fdiv.ll

Modified: llvm/trunk/test/Transforms/InstCombine/fdiv.ll
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/Transforms/InstCombine/fdiv.ll?rev=362231&r1=362230&r2=362231&view=diff
==============================================================================
--- llvm/trunk/test/Transforms/InstCombine/fdiv.ll (original)
+++ llvm/trunk/test/Transforms/InstCombine/fdiv.ll Fri May 31 08:10:34 2019
@@ -198,6 +198,39 @@ define float @fneg_fneg(float %x, float
   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, f
   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 f
   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> <float -0.0, float -0.0>, %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> <float -0.0, float -0.0>, %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_div
   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_divi
   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:%.*]], <float -3.000000e+00, float 8.000000e+00>
@@ -263,6 +360,16 @@ define <2 x float> @fneg_dividend_consta
   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:%.*]], <float -3.000000e+00, float 8.000000e+00>
+; CHECK-NEXT:    ret <2 x float> [[DIV]]
+;
+  %neg = fneg <2 x float> %x
+  %div = fdiv ninf <2 x float> %neg, <float 3.0, float -8.0>
+  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:%.*]], <float -3.000000e+00, float 8.000000e+00>
@@ -283,6 +390,17 @@ define <2 x float> @fneg_divisor_constan
   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> <float 3.000000e+00, float -5.000000e+00>, [[X:%.*]]
+; CHECK-NEXT:    ret <2 x float> [[DIV]]
+;
+  %neg = fneg <2 x float> %x
+  %div = fdiv afn <2 x float> <float -3.0, float 5.0>, %neg
+  ret <2 x float> %div
+}
+
+
 ; X / (X * Y) --> 1.0 / Y
 
 define float @div_factor(float %x, float %y) {




More information about the llvm-commits mailing list