[llvm] r362633 - [X86][SSE] Add vector tests to cover more isNegatibleForFree/GetNegatedExpression cases (PR42105)

Simon Pilgrim via llvm-commits llvm-commits at lists.llvm.org
Wed Jun 5 11:55:54 PDT 2019


Author: rksimon
Date: Wed Jun  5 11:55:54 2019
New Revision: 362633

URL: http://llvm.org/viewvc/llvm-project?rev=362633&view=rev
Log:
[X86][SSE] Add vector tests to cover more isNegatibleForFree/GetNegatedExpression cases (PR42105)

Some already combine correctly, but vector constant analysis is weak.

Modified:
    llvm/trunk/test/CodeGen/X86/dag-fmf-cse.ll
    llvm/trunk/test/CodeGen/X86/fdiv.ll
    llvm/trunk/test/CodeGen/X86/fp-fold.ll

Modified: llvm/trunk/test/CodeGen/X86/dag-fmf-cse.ll
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/CodeGen/X86/dag-fmf-cse.ll?rev=362633&r1=362632&r2=362633&view=diff
==============================================================================
--- llvm/trunk/test/CodeGen/X86/dag-fmf-cse.ll (original)
+++ llvm/trunk/test/CodeGen/X86/dag-fmf-cse.ll Wed Jun  5 11:55:54 2019
@@ -12,7 +12,6 @@ define float @fmf_should_not_break_cse(f
 ; CHECK-NEXT:    vmulss %xmm1, %xmm0, %xmm0
 ; CHECK-NEXT:    vaddss %xmm0, %xmm0, %xmm0
 ; CHECK-NEXT:    retq
-
   %mul1 = fmul fast float %a, %b
   %nega = fsub fast float 0.0, %a
   %mul2 = fmul fast float %nega, %b
@@ -20,3 +19,15 @@ define float @fmf_should_not_break_cse(f
   ret float %abx2
 }
 
+define <4 x float> @fmf_should_not_break_cse_vector(<4 x float> %a, <4 x float> %b) {
+; CHECK-LABEL: fmf_should_not_break_cse_vector:
+; CHECK:       # %bb.0:
+; CHECK-NEXT:    vmulps %xmm1, %xmm0, %xmm0
+; CHECK-NEXT:    vaddps %xmm0, %xmm0, %xmm0
+; CHECK-NEXT:    retq
+  %mul1 = fmul fast <4 x float> %a, %b
+  %nega = fsub fast <4 x float> <float 0.0, float 0.0, float 0.0, float 0.0>, %a
+  %mul2 = fmul fast <4 x float> %nega, %b
+  %abx2 = fsub fast <4 x float> %mul1, %mul2
+  ret <4 x float> %abx2
+}

Modified: llvm/trunk/test/CodeGen/X86/fdiv.ll
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/CodeGen/X86/fdiv.ll?rev=362633&r1=362632&r2=362633&view=diff
==============================================================================
--- llvm/trunk/test/CodeGen/X86/fdiv.ll (original)
+++ llvm/trunk/test/CodeGen/X86/fdiv.ll Wed Jun  5 11:55:54 2019
@@ -65,5 +65,16 @@ define float @double_negative(float %x,
   ret float %div
 }
 
+define <4 x float> @double_negative_vector(<4 x float> %x, <4 x float> %y) #0 {
+; CHECK-LABEL: double_negative_vector:
+; CHECK:       # %bb.0:
+; CHECK-NEXT:    divps %xmm1, %xmm0
+; CHECK-NEXT:    retq
+  %neg1 = fsub <4 x float> <float -0.0, float -0.0, float -0.0, float -0.0>, %x
+  %neg2 = fsub <4 x float> <float -0.0, float -0.0, float -0.0, float -0.0>, %y
+  %div = fdiv <4 x float> %neg1, %neg2
+  ret <4 x float> %div
+}
+
 attributes #0 = { "unsafe-fp-math"="false" }
 

Modified: llvm/trunk/test/CodeGen/X86/fp-fold.ll
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/CodeGen/X86/fp-fold.ll?rev=362633&r1=362632&r2=362633&view=diff
==============================================================================
--- llvm/trunk/test/CodeGen/X86/fp-fold.ll (original)
+++ llvm/trunk/test/CodeGen/X86/fp-fold.ll Wed Jun  5 11:55:54 2019
@@ -99,6 +99,18 @@ define float @fsub_neg_y(float %x, float
   ret float %r
 }
 
+define <4 x float> @fsub_neg_y_vector(<4 x float> %x, <4 x float>%y) {
+; ANY-LABEL: fsub_neg_y_vector:
+; ANY:       # %bb.0:
+; ANY-NEXT:    mulps {{.*}}(%rip), %xmm0
+; ANY-NEXT:    xorps {{.*}}(%rip), %xmm0
+; ANY-NEXT:    retq
+  %mul = fmul <4 x float> %x, <float 5.0, float 5.0, float 5.0, float 5.0>
+  %add = fadd <4 x float> %mul, %y
+  %r = fsub nsz reassoc <4 x float> %y, %add
+  ret <4 x float> %r
+}
+
 define float @fsub_neg_y_commute(float %x, float %y) {
 ; ANY-LABEL: fsub_neg_y_commute:
 ; ANY:       # %bb.0:
@@ -109,6 +121,19 @@ define float @fsub_neg_y_commute(float %
   %r = fsub nsz reassoc float %y, %add
   ret float %r
 }
+
+define <4 x float> @fsub_neg_y_commute_vector(<4 x float> %x, <4 x float> %y) {
+; ANY-LABEL: fsub_neg_y_commute_vector:
+; ANY:       # %bb.0:
+; ANY-NEXT:    mulps {{.*}}(%rip), %xmm0
+; ANY-NEXT:    xorps {{.*}}(%rip), %xmm0
+; ANY-NEXT:    retq
+  %mul = fmul <4 x float> %x, <float 5.0, float 5.0, float 5.0, float 5.0>
+  %add = fadd <4 x float> %y, %mul
+  %r = fsub nsz reassoc <4 x float> %y, %add
+  ret <4 x float> %r
+}
+
 ; Y - (X + Y) --> -X
 
 define float @fsub_fadd_common_op_fneg(float %x, float %y) {
@@ -172,6 +197,19 @@ define float @fsub_negzero(float %x) {
   ret float %r
 }
 
+define <4 x float> @fsub_negzero_vector(<4 x float> %x) {
+; STRICT-LABEL: fsub_negzero_vector:
+; STRICT:       # %bb.0:
+; STRICT-NEXT:    subps {{.*}}(%rip), %xmm0
+; STRICT-NEXT:    retq
+;
+; UNSAFE-LABEL: fsub_negzero_vector:
+; UNSAFE:       # %bb.0:
+; UNSAFE-NEXT:    retq
+  %r = fsub <4 x float> %x, <float -0.0, float -0.0, float -0.0, float -0.0>
+  ret <4 x float> %r
+}
+
 define float @fsub_zero_nsz_1(float %x) {
 ; ANY-LABEL: fsub_zero_nsz_1:
 ; ANY:       # %bb.0:




More information about the llvm-commits mailing list