Pre-commit unary fneg tests to InstSimplify

llvm-svn: 360808
diff --git a/llvm/test/Transforms/InstSimplify/fast-math.ll b/llvm/test/Transforms/InstSimplify/fast-math.ll
index 5f981ed..3dc2ad2 100644
--- a/llvm/test/Transforms/InstSimplify/fast-math.ll
+++ b/llvm/test/Transforms/InstSimplify/fast-math.ll
@@ -106,8 +106,8 @@
 ; https://bugs.llvm.org/show_bug.cgi?id=26958
 ; https://bugs.llvm.org/show_bug.cgi?id=27151
 
-define float @fadd_fneg_nan(float %x) {
-; CHECK-LABEL: @fadd_fneg_nan(
+define float @fadd_binary_fneg_nan(float %x) {
+; CHECK-LABEL: @fadd_binary_fneg_nan(
 ; CHECK-NEXT:    [[T:%.*]] = fsub nnan float -0.000000e+00, [[X:%.*]]
 ; CHECK-NEXT:    [[COULD_BE_NAN:%.*]] = fadd ninf float [[T]], [[X]]
 ; CHECK-NEXT:    ret float [[COULD_BE_NAN]]
@@ -117,8 +117,19 @@
   ret float %could_be_nan
 }
 
-define float @fadd_fneg_nan_commute(float %x) {
-; CHECK-LABEL: @fadd_fneg_nan_commute(
+define float @fadd_unary_fneg_nan(float %x) {
+; CHECK-LABEL: @fadd_unary_fneg_nan(
+; CHECK-NEXT:    [[T:%.*]] = fneg nnan float [[X:%.*]]
+; CHECK-NEXT:    [[COULD_BE_NAN:%.*]] = fadd ninf float [[T]], [[X]]
+; CHECK-NEXT:    ret float [[COULD_BE_NAN]]
+;
+  %t = fneg nnan float %x
+  %could_be_nan = fadd ninf float %t, %x
+  ret float %could_be_nan
+}
+
+define float @fadd_binary_fneg_nan_commute(float %x) {
+; CHECK-LABEL: @fadd_binary_fneg_nan_commute(
 ; CHECK-NEXT:    [[T:%.*]] = fsub nnan ninf float -0.000000e+00, [[X:%.*]]
 ; CHECK-NEXT:    [[COULD_BE_NAN:%.*]] = fadd float [[X]], [[T]]
 ; CHECK-NEXT:    ret float [[COULD_BE_NAN]]
@@ -128,6 +139,17 @@
   ret float %could_be_nan
 }
 
+define float @fadd_unary_fneg_nan_commute(float %x) {
+; CHECK-LABEL: @fadd_unary_fneg_nan_commute(
+; CHECK-NEXT:    [[T:%.*]] = fneg nnan ninf float [[X:%.*]]
+; CHECK-NEXT:    [[COULD_BE_NAN:%.*]] = fadd float [[X]], [[T]]
+; CHECK-NEXT:    ret float [[COULD_BE_NAN]]
+;
+  %t = fneg nnan ninf float %x
+  %could_be_nan = fadd float %x, %t
+  ret float %could_be_nan
+}
+
 ; X + (0.0 - X) --> 0.0 (with nnan on the fadd)
 
 define float @fadd_fsub_nnan_ninf(float %x) {
@@ -194,6 +216,18 @@
   ret float %ret
 }
 
+; fsub nsz 0.0, (fneg X) ==> X
+define float @fneg_x(float %a) {
+; CHECK-LABEL: @fneg_x(
+; CHECK-NEXT:    [[T1:%.*]] = fsub float 0.000000e+00, [[A:%.*]]
+; CHECK-NEXT:    [[RET:%.*]] = fneg nsz float [[T1]]
+; CHECK-NEXT:    ret float [[RET]]
+;
+  %t1 = fsub float 0.0, %a
+  %ret = fneg nsz float %t1
+  ret float %ret
+}
+
 define <2 x float> @fsub_0_0_x_vec_undef1(<2 x float> %a) {
 ; CHECK-LABEL: @fsub_0_0_x_vec_undef1(
 ; CHECK-NEXT:    ret <2 x float> [[A:%.*]]
@@ -203,6 +237,17 @@
   ret <2 x float> %ret
 }
 
+define <2 x float> @fneg_x_vec_undef1(<2 x float> %a) {
+; CHECK-LABEL: @fneg_x_vec_undef1(
+; CHECK-NEXT:    [[T1:%.*]] = fsub <2 x float> <float 0.000000e+00, float undef>, [[A:%.*]]
+; CHECK-NEXT:    [[RET:%.*]] = fneg nsz <2 x float> [[T1]]
+; CHECK-NEXT:    ret <2 x float> [[RET]]
+;
+  %t1 = fsub <2 x float> <float 0.0, float undef>, %a
+  %ret = fneg nsz <2 x float> %t1
+  ret <2 x float> %ret
+}
+
 define <2 x float> @fsub_0_0_x_vec_undef2(<2 x float> %a) {
 ; CHECK-LABEL: @fsub_0_0_x_vec_undef2(
 ; CHECK-NEXT:    ret <2 x float> [[A:%.*]]