X-Git-Url: http://plrg.eecs.uci.edu/git/?a=blobdiff_plain;f=test%2FCodeGen%2FX86%2Fvec_fneg.ll;h=a85ae984d8e60322fdbd2d8abcb40ff81e9c0761;hb=2fa91afc4677766e7c29d1784bc5575e9cb791ac;hp=03765d681cc323efdb75013eb194c24be2763f85;hpb=7f88d9c62b9942d01185ef434010e4e6e92b4d33;p=oota-llvm.git diff --git a/test/CodeGen/X86/vec_fneg.ll b/test/CodeGen/X86/vec_fneg.ll index 03765d681cc..a85ae984d8e 100644 --- a/test/CodeGen/X86/vec_fneg.ll +++ b/test/CodeGen/X86/vec_fneg.ll @@ -1,11 +1,45 @@ -; RUN: llvm-as < %s | llc -march=x86 -mattr=+sse2 +; RUN: llc < %s -mtriple=x86_64-unknown-unknown -mattr=sse | FileCheck %s +; FNEG is defined as subtraction from -0.0. + +; This test verifies that we use an xor with a constant to flip the sign bits; no subtraction needed. define <4 x float> @t1(<4 x float> %Q) { - %tmp15 = sub <4 x float> < float -0.000000e+00, float -0.000000e+00, float -0.000000e+00, float -0.000000e+00 >, %Q - ret <4 x float> %tmp15 +; CHECK-LABEL: t1: +; CHECK: xorps {{.*}}LCPI0_0{{.*}}, %xmm0 +; CHECK-NEXT: retq + %tmp = fsub <4 x float> < float -0.000000e+00, float -0.000000e+00, float -0.000000e+00, float -0.000000e+00 >, %Q + ret <4 x float> %tmp } +; This test verifies that we generate an FP subtraction because "0.0 - x" is not an fneg. define <4 x float> @t2(<4 x float> %Q) { - %tmp15 = sub <4 x float> zeroinitializer, %Q - ret <4 x float> %tmp15 +; CHECK-LABEL: t2: +; CHECK: xorps %[[X:xmm[0-9]+]], %[[X]] +; CHECK-NEXT: subps %xmm0, %[[X]] +; CHECK-NEXT: movaps %[[X]], %xmm0 +; CHECK-NEXT: retq + %tmp = fsub <4 x float> zeroinitializer, %Q + ret <4 x float> %tmp +} + +; If we're bitcasting an integer to an FP vector, we should avoid the FPU/vector unit entirely. +; Make sure that we're flipping the sign bit and only the sign bit of each float. +; So instead of something like this: +; movd %rdi, %xmm0 +; xorps .LCPI2_0(%rip), %xmm0 +; +; We should generate: +; movabsq (put sign bit mask in integer register)) +; xorq (flip sign bits) +; movd (move to xmm return register) + +define <2 x float> @fneg_bitcast(i64 %i) { +; CHECK-LABEL: fneg_bitcast: +; CHECK: movabsq $-9223372034707292160, %rax # imm = 0x8000000080000000 +; CHECK-NEXT: xorq %rdi, %rax +; CHECK-NEXT: movd %rax, %xmm0 +; CHECK-NEXT: retq + %bitcast = bitcast i64 %i to <2 x float> + %fneg = fsub <2 x float> , %bitcast + ret <2 x float> %fneg }