[llvm] r363093 - [NFC][CodeGen] Add unary FNeg tests to X86/combine-fcopysign.ll X86/dag-fmf-cse.ll X86/fast-isel-fneg.ll X86/fdiv.ll
Cameron McInally via llvm-commits
llvm-commits at lists.llvm.org
Tue Jun 11 11:55:13 PDT 2019
Author: mcinally
Date: Tue Jun 11 11:55:13 2019
New Revision: 363093
URL: http://llvm.org/viewvc/llvm-project?rev=363093&view=rev
Log:
[NFC][CodeGen] Add unary FNeg tests to X86/combine-fcopysign.ll X86/dag-fmf-cse.ll X86/fast-isel-fneg.ll X86/fdiv.ll
Modified:
llvm/trunk/test/CodeGen/X86/combine-fcopysign.ll
llvm/trunk/test/CodeGen/X86/dag-fmf-cse.ll
llvm/trunk/test/CodeGen/X86/fast-isel-fneg.ll
llvm/trunk/test/CodeGen/X86/fdiv.ll
Modified: llvm/trunk/test/CodeGen/X86/combine-fcopysign.ll
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/CodeGen/X86/combine-fcopysign.ll?rev=363093&r1=363092&r2=363093&view=diff
==============================================================================
--- llvm/trunk/test/CodeGen/X86/combine-fcopysign.ll (original)
+++ llvm/trunk/test/CodeGen/X86/combine-fcopysign.ll Tue Jun 11 11:55:13 2019
@@ -102,6 +102,23 @@ define <4 x float> @combine_vec_fcopysig
ret <4 x float> %3
}
+define <4 x float> @combine_vec_fcopysign_unary_fneg_fabs_sgn(<4 x float> %x, <4 x float> %y) {
+; SSE-LABEL: combine_vec_fcopysign_unary_fneg_fabs_sgn:
+; SSE: # %bb.0:
+; SSE-NEXT: orps {{.*}}(%rip), %xmm0
+; SSE-NEXT: retq
+;
+; AVX-LABEL: combine_vec_fcopysign_unary_fneg_fabs_sgn:
+; AVX: # %bb.0:
+; AVX-NEXT: vbroadcastss {{.*#+}} xmm1 = [-0.0E+0,-0.0E+0,-0.0E+0,-0.0E+0]
+; AVX-NEXT: vorps %xmm1, %xmm0, %xmm0
+; AVX-NEXT: retq
+ %1 = call <4 x float> @llvm.fabs.v4f32(<4 x float> %y)
+ %2 = fneg <4 x float> %1
+ %3 = call <4 x float> @llvm.copysign.v4f32(<4 x float> %x, <4 x float> %2)
+ ret <4 x float> %3
+}
+
; copysign(fabs(x), y) -> copysign(x, y)
define <4 x float> @combine_vec_fcopysign_fabs_mag(<4 x float> %x, <4 x float> %y) {
; SSE-LABEL: combine_vec_fcopysign_fabs_mag:
@@ -145,6 +162,27 @@ define <4 x float> @combine_vec_fcopysig
%2 = call <4 x float> @llvm.copysign.v4f32(<4 x float> %1, <4 x float> %y)
ret <4 x float> %2
}
+
+define <4 x float> @combine_vec_fcopysign_unary_fneg_mag(<4 x float> %x, <4 x float> %y) {
+; SSE-LABEL: combine_vec_fcopysign_unary_fneg_mag:
+; SSE: # %bb.0:
+; SSE-NEXT: andps {{.*}}(%rip), %xmm1
+; SSE-NEXT: andps {{.*}}(%rip), %xmm0
+; SSE-NEXT: orps %xmm1, %xmm0
+; SSE-NEXT: retq
+;
+; AVX-LABEL: combine_vec_fcopysign_unary_fneg_mag:
+; AVX: # %bb.0:
+; AVX-NEXT: vbroadcastss {{.*#+}} xmm2 = [-0.0E+0,-0.0E+0,-0.0E+0,-0.0E+0]
+; AVX-NEXT: vandps %xmm2, %xmm1, %xmm1
+; AVX-NEXT: vbroadcastss {{.*#+}} xmm2 = [NaN,NaN,NaN,NaN]
+; AVX-NEXT: vandps %xmm2, %xmm0, %xmm0
+; AVX-NEXT: vorps %xmm1, %xmm0, %xmm0
+; AVX-NEXT: retq
+ %1 = fneg <4 x float> %x
+ %2 = call <4 x float> @llvm.copysign.v4f32(<4 x float> %1, <4 x float> %y)
+ ret <4 x float> %2
+}
; copysign(copysign(x,z), y) -> copysign(x, y)
define <4 x float> @combine_vec_fcopysign_fcopysign_mag(<4 x float> %x, <4 x float> %y, <4 x float> %z) {
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=363093&r1=363092&r2=363093&view=diff
==============================================================================
--- llvm/trunk/test/CodeGen/X86/dag-fmf-cse.ll (original)
+++ llvm/trunk/test/CodeGen/X86/dag-fmf-cse.ll Tue Jun 11 11:55:13 2019
@@ -19,6 +19,19 @@ define float @fmf_should_not_break_cse(f
ret float %abx2
}
+define float @fmf_should_not_break_cse_unary_fneg(float %a, float %b) {
+; CHECK-LABEL: fmf_should_not_break_cse_unary_fneg:
+; CHECK: # %bb.0:
+; CHECK-NEXT: vmulss %xmm1, %xmm0, %xmm0
+; CHECK-NEXT: vaddss %xmm0, %xmm0, %xmm0
+; CHECK-NEXT: retq
+ %mul1 = fmul fast float %a, %b
+ %nega = fneg fast float %a
+ %mul2 = fmul fast float %nega, %b
+ %abx2 = fsub fast float %mul1, %mul2
+ 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:
@@ -30,4 +43,17 @@ define <4 x float> @fmf_should_not_break
%mul2 = fmul fast <4 x float> %nega, %b
%abx2 = fsub fast <4 x float> %mul1, %mul2
ret <4 x float> %abx2
+}
+
+define <4 x float> @fmf_should_not_break_cse_vector_unary_fneg(<4 x float> %a, <4 x float> %b) {
+; CHECK-LABEL: fmf_should_not_break_cse_vector_unary_fneg:
+; 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 = fneg fast <4 x float> %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/fast-isel-fneg.ll
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/CodeGen/X86/fast-isel-fneg.ll?rev=363093&r1=363092&r2=363093&view=diff
==============================================================================
--- llvm/trunk/test/CodeGen/X86/fast-isel-fneg.ll (original)
+++ llvm/trunk/test/CodeGen/X86/fast-isel-fneg.ll Tue Jun 11 11:55:13 2019
@@ -74,6 +74,31 @@ define void @goo(double* %x, double* %y)
ret void
}
+define void @goo_unary_fneg(double* %x, double* %y) nounwind {
+; CHECK-LABEL: goo_unary_fneg:
+; CHECK: ## %bb.0:
+; CHECK-NEXT: movq {{.*#+}} xmm0 = mem[0],zero
+; CHECK-NEXT: movq %xmm0, %rax
+; CHECK-NEXT: movabsq $-9223372036854775808, %rcx ## imm = 0x8000000000000000
+; CHECK-NEXT: xorq %rax, %rcx
+; CHECK-NEXT: movq %rcx, %xmm0
+; CHECK-NEXT: movq %xmm0, (%rsi)
+; CHECK-NEXT: retq
+;
+; SSE2-LABEL: goo_unary_fneg:
+; SSE2: # %bb.0:
+; SSE2-NEXT: movl {{[0-9]+}}(%esp), %eax
+; SSE2-NEXT: movl {{[0-9]+}}(%esp), %ecx
+; SSE2-NEXT: movsd {{.*#+}} xmm0 = mem[0],zero
+; SSE2-NEXT: xorps {{\.LCPI.*}}, %xmm0
+; SSE2-NEXT: movsd %xmm0, (%eax)
+; SSE2-NEXT: retl
+ %a = load double, double* %x
+ %b = fneg double %a
+ store double %b, double* %y
+ ret void
+}
+
define void @loo(float* %x, float* %y) nounwind {
; CHECK-LABEL: loo:
; CHECK: ## %bb.0:
@@ -99,6 +124,32 @@ define void @loo(float* %x, float* %y) n
store float %b, float* %y
ret void
}
+
+define void @loo_unary_fneg(float* %x, float* %y) nounwind {
+; CHECK-LABEL: loo_unary_fneg:
+; CHECK: ## %bb.0:
+; CHECK-NEXT: movd {{.*#+}} xmm0 = mem[0],zero,zero,zero
+; CHECK-NEXT: movd %xmm0, %eax
+; CHECK-NEXT: xorl $2147483648, %eax ## imm = 0x80000000
+; CHECK-NEXT: movd %eax, %xmm0
+; CHECK-NEXT: movd %xmm0, (%rsi)
+; CHECK-NEXT: retq
+;
+; SSE2-LABEL: loo_unary_fneg:
+; SSE2: # %bb.0:
+; SSE2-NEXT: movl {{[0-9]+}}(%esp), %eax
+; SSE2-NEXT: movl {{[0-9]+}}(%esp), %ecx
+; SSE2-NEXT: movd {{.*#+}} xmm0 = mem[0],zero,zero,zero
+; SSE2-NEXT: movd %xmm0, %ecx
+; SSE2-NEXT: xorl $2147483648, %ecx # imm = 0x80000000
+; SSE2-NEXT: movd %ecx, %xmm0
+; SSE2-NEXT: movd %xmm0, (%eax)
+; SSE2-NEXT: retl
+ %a = load float, float* %x
+ %b = fneg float %a
+ store float %b, float* %y
+ ret void
+}
define double @too(double %x) nounwind {
; CHECK-LABEL: too:
Modified: llvm/trunk/test/CodeGen/X86/fdiv.ll
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/CodeGen/X86/fdiv.ll?rev=363093&r1=363092&r2=363093&view=diff
==============================================================================
--- llvm/trunk/test/CodeGen/X86/fdiv.ll (original)
+++ llvm/trunk/test/CodeGen/X86/fdiv.ll Tue Jun 11 11:55:13 2019
@@ -65,6 +65,39 @@ define float @double_negative(float %x,
ret float %div
}
+define float @double_negative_unary_fneg_x_unary_fneg_y(float %x, float %y) #0 {
+; CHECK-LABEL: double_negative_unary_fneg_x_unary_fneg_y:
+; CHECK: # %bb.0:
+; CHECK-NEXT: divss %xmm1, %xmm0
+; CHECK-NEXT: retq
+ %neg1 = fneg float %x
+ %neg2 = fneg float %y
+ %div = fdiv float %neg1, %neg2
+ ret float %div
+}
+
+define float @double_negative_unary_fneg_x(float %x, float %y) #0 {
+; CHECK-LABEL: double_negative_unary_fneg_x:
+; CHECK: # %bb.0:
+; CHECK-NEXT: divss %xmm1, %xmm0
+; CHECK-NEXT: retq
+ %neg1 = fneg float %x
+ %neg2 = fsub float -0.0, %y
+ %div = fdiv float %neg1, %neg2
+ ret float %div
+}
+
+define float @double_negative_unary_fneg_y(float %x, float %y) #0 {
+; CHECK-LABEL: double_negative_unary_fneg_y:
+; CHECK: # %bb.0:
+; CHECK-NEXT: divss %xmm1, %xmm0
+; CHECK-NEXT: retq
+ %neg1 = fsub float -0.0, %x
+ %neg2 = fneg float %y
+ %div = fdiv float %neg1, %neg2
+ 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:
@@ -75,6 +108,39 @@ define <4 x float> @double_negative_vect
%div = fdiv <4 x float> %neg1, %neg2
ret <4 x float> %div
}
+
+define <4 x float> @double_negative_vector_unary_fneg_x_unary_fneg_y(<4 x float> %x, <4 x float> %y) #0 {
+; CHECK-LABEL: double_negative_vector_unary_fneg_x_unary_fneg_y:
+; CHECK: # %bb.0:
+; CHECK-NEXT: divps %xmm1, %xmm0
+; CHECK-NEXT: retq
+ %neg1 = fneg <4 x float> %x
+ %neg2 = fneg <4 x float> %y
+ %div = fdiv <4 x float> %neg1, %neg2
+ ret <4 x float> %div
+}
+
+define <4 x float> @double_negative_vector_unary_fneg_x(<4 x float> %x, <4 x float> %y) #0 {
+; CHECK-LABEL: double_negative_vector_unary_fneg_x:
+; CHECK: # %bb.0:
+; CHECK-NEXT: divps %xmm1, %xmm0
+; CHECK-NEXT: retq
+ %neg1 = fneg <4 x float> %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
+}
+
+define <4 x float> @double_negative_vector_unary_fneg_y(<4 x float> %x, <4 x float> %y) #0 {
+; CHECK-LABEL: double_negative_vector_unary_fneg_y:
+; 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 = fneg <4 x float> %y
+ %div = fdiv <4 x float> %neg1, %neg2
+ ret <4 x float> %div
+}
attributes #0 = { "unsafe-fp-math"="false" }
More information about the llvm-commits
mailing list