• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1; RUN: llc < %s -mtriple=x86_64-unknown-unknown -mattr=sse | FileCheck %s
2
3; FNEG is defined as subtraction from -0.0.
4
5; This test verifies that we use an xor with a constant to flip the sign bits; no subtraction needed.
6define <4 x float> @t1(<4 x float> %Q) {
7; CHECK-LABEL: t1:
8; CHECK: xorps	{{.*}}LCPI0_0{{.*}}, %xmm0
9; CHECK-NEXT: retq
10        %tmp = fsub <4 x float> < float -0.000000e+00, float -0.000000e+00, float -0.000000e+00, float -0.000000e+00 >, %Q
11	ret <4 x float> %tmp
12}
13
14; This test verifies that we generate an FP subtraction because "0.0 - x" is not an fneg.
15define <4 x float> @t2(<4 x float> %Q) {
16; CHECK-LABEL: t2:
17; CHECK: xorps	%[[X:xmm[0-9]+]], %[[X]]
18; CHECK-NEXT: subps	%xmm0, %[[X]]
19; CHECK-NEXT: movaps	%[[X]], %xmm0
20; CHECK-NEXT: retq
21        %tmp = fsub <4 x float> zeroinitializer, %Q
22	ret <4 x float> %tmp
23}
24
25; If we're bitcasting an integer to an FP vector, we should avoid the FPU/vector unit entirely.
26; Make sure that we're flipping the sign bit and only the sign bit of each float.
27; So instead of something like this:
28;    movd	%rdi, %xmm0
29;    xorps	.LCPI2_0(%rip), %xmm0
30;
31; We should generate:
32;    movabsq     (put sign bit mask in integer register))
33;    xorq        (flip sign bits)
34;    movd        (move to xmm return register)
35
36define <2 x float> @fneg_bitcast(i64 %i) {
37; CHECK-LABEL: fneg_bitcast:
38; CHECK:	movabsq	$-9223372034707292160, %rax # imm = 0x8000000080000000
39; CHECK-NEXT:	xorq	%rdi, %rax
40; CHECK-NEXT:	movd	%rax, %xmm0
41; CHECK-NEXT:	retq
42  %bitcast = bitcast i64 %i to <2 x float>
43  %fneg = fsub <2 x float> <float -0.0, float -0.0>, %bitcast
44  ret <2 x float> %fneg
45}
46