1 ; NOTE: Assertions have been autogenerated by utils/update_llc_test_checks.py
2 ; RUN: llc < %s -mtriple=i686-unknown-unknown -mattr=+sse | FileCheck %s --check-prefix=X32-SSE --check-prefix=X32-SSE1
3 ; RUN: llc < %s -mtriple=i686-unknown-unknown -mattr=+sse2 | FileCheck %s --check-prefix=X32-SSE --check-prefix=X32-SSE2
4 ; RUN: llc < %s -mtriple=x86_64-unknown-unknown -mattr=-sse2 | FileCheck %s --check-prefix=X64-SSE --check-prefix=X64-SSE1
5 ; RUN: llc < %s -mtriple=x86_64-unknown-unknown -mattr=+sse2 | FileCheck %s --check-prefix=X64-SSE --check-prefix=X64-SSE2
7 ; FNEG is defined as subtraction from -0.0.
9 ; This test verifies that we use an xor with a constant to flip the sign bits; no subtraction needed.
10 define <4 x float> @t1(<4 x float> %Q) nounwind {
13 ; X32-SSE-NEXT: xorps {{\.LCPI.*}}, %xmm0
18 ; X64-SSE-NEXT: xorps {{.*}}(%rip), %xmm0
20 %tmp = fsub <4 x float> < float -0.000000e+00, float -0.000000e+00, float -0.000000e+00, float -0.000000e+00 >, %Q
24 ; This test verifies that we generate an FP subtraction because "0.0 - x" is not an fneg.
25 define <4 x float> @t2(<4 x float> %Q) nounwind {
28 ; X32-SSE-NEXT: xorps %xmm1, %xmm1
29 ; X32-SSE-NEXT: subps %xmm0, %xmm1
30 ; X32-SSE-NEXT: movaps %xmm1, %xmm0
35 ; X64-SSE-NEXT: xorps %xmm1, %xmm1
36 ; X64-SSE-NEXT: subps %xmm0, %xmm1
37 ; X64-SSE-NEXT: movaps %xmm1, %xmm0
39 %tmp = fsub <4 x float> zeroinitializer, %Q
43 ; If we're bitcasting an integer to an FP vector, we should avoid the FPU/vector unit entirely.
44 ; Make sure that we're flipping the sign bit and only the sign bit of each float.
45 ; So instead of something like this:
47 ; xorps .LCPI2_0(%rip), %xmm0
50 ; movabsq (put sign bit mask in integer register))
51 ; xorq (flip sign bits)
52 ; movd (move to xmm return register)
54 define <2 x float> @fneg_bitcast(i64 %i) nounwind {
55 ; X32-SSE1-LABEL: fneg_bitcast:
57 ; X32-SSE1-NEXT: pushl %ebp
58 ; X32-SSE1-NEXT: movl %esp, %ebp
59 ; X32-SSE1-NEXT: andl $-16, %esp
60 ; X32-SSE1-NEXT: subl $32, %esp
61 ; X32-SSE1-NEXT: movl $-2147483648, %eax # imm = 0x80000000
62 ; X32-SSE1-NEXT: movl 12(%ebp), %ecx
63 ; X32-SSE1-NEXT: xorl %eax, %ecx
64 ; X32-SSE1-NEXT: movl %ecx, {{[0-9]+}}(%esp)
65 ; X32-SSE1-NEXT: xorl 8(%ebp), %eax
66 ; X32-SSE1-NEXT: movl %eax, (%esp)
67 ; X32-SSE1-NEXT: movaps (%esp), %xmm0
68 ; X32-SSE1-NEXT: movl %ebp, %esp
69 ; X32-SSE1-NEXT: popl %ebp
72 ; X32-SSE2-LABEL: fneg_bitcast:
74 ; X32-SSE2-NEXT: movl $-2147483648, %eax # imm = 0x80000000
75 ; X32-SSE2-NEXT: movl {{[0-9]+}}(%esp), %ecx
76 ; X32-SSE2-NEXT: xorl %eax, %ecx
77 ; X32-SSE2-NEXT: movd %ecx, %xmm1
78 ; X32-SSE2-NEXT: xorl {{[0-9]+}}(%esp), %eax
79 ; X32-SSE2-NEXT: movd %eax, %xmm0
80 ; X32-SSE2-NEXT: punpckldq {{.*#+}} xmm0 = xmm0[0],xmm1[0],xmm0[1],xmm1[1]
83 ; X64-SSE1-LABEL: fneg_bitcast:
85 ; X64-SSE1-NEXT: movabsq $-9223372034707292160, %rax # imm = 0x8000000080000000
86 ; X64-SSE1-NEXT: xorq %rdi, %rax
87 ; X64-SSE1-NEXT: movq %rax, -{{[0-9]+}}(%rsp)
88 ; X64-SSE1-NEXT: movaps -{{[0-9]+}}(%rsp), %xmm0
91 ; X64-SSE2-LABEL: fneg_bitcast:
93 ; X64-SSE2-NEXT: movabsq $-9223372034707292160, %rax # imm = 0x8000000080000000
94 ; X64-SSE2-NEXT: xorq %rdi, %rax
95 ; X64-SSE2-NEXT: movq %rax, %xmm0
97 %bitcast = bitcast i64 %i to <2 x float>
98 %fneg = fsub <2 x float> <float -0.0, float -0.0>, %bitcast
102 define <4 x float> @fneg_undef_elts_v4f32(<4 x float> %x) {
103 ; X32-SSE-LABEL: fneg_undef_elts_v4f32:
105 ; X32-SSE-NEXT: xorps {{\.LCPI.*}}, %xmm0
108 ; X64-SSE-LABEL: fneg_undef_elts_v4f32:
110 ; X64-SSE-NEXT: xorps {{.*}}(%rip), %xmm0
112 %r = fsub <4 x float> <float -0.0, float undef, float undef, float -0.0>, %x
116 ; This isn't fneg, but similarly check that (X - 0.0) is simplified.
118 define <4 x float> @fsub0_undef_elts_v4f32(<4 x float> %x) {
119 ; X32-SSE-LABEL: fsub0_undef_elts_v4f32:
123 ; X64-SSE-LABEL: fsub0_undef_elts_v4f32:
126 %r = fsub <4 x float> %x, <float 0.0, float undef, float 0.0, float undef>
130 define <4 x float> @fneg(<4 x float> %Q) nounwind {
131 ; X32-SSE-LABEL: fneg:
133 ; X32-SSE-NEXT: xorps {{\.LCPI.*}}, %xmm0
136 ; X64-SSE-LABEL: fneg:
138 ; X64-SSE-NEXT: xorps {{.*}}(%rip), %xmm0
140 %tmp = fneg <4 x float> %Q