[x86] enable machine combiner reassociations for 256-bit vector FP mul/add
[oota-llvm.git] / test / CodeGen / X86 / sse-scalar-fp-arith-unary.ll
1 ; RUN: llc -mtriple=x86_64-unknown-unknown -mattr=sse2 < %s   | FileCheck --check-prefix=SSE %s
2 ; RUN: llc -mtriple=x86_64-unknown-unknown -mattr=sse4.1 < %s | FileCheck --check-prefix=SSE %s
3 ; RUN: llc -mtriple=x86_64-unknown-unknown -mattr=avx < %s    | FileCheck --check-prefix=AVX %s
4
5 ; PR21507 - https://llvm.org/bugs/show_bug.cgi?id=21507
6 ; Each function should be a single math op; no extra moves.
7
8
9 define <4 x float> @recip(<4 x float> %x) {
10 ; SSE-LABEL: recip:
11 ; SSE:       # BB#0:
12 ; SSE-NEXT:    rcpss %xmm0, %xmm0
13 ; SSE-NEXT:    retq
14 ;
15 ; AVX-LABEL: recip:
16 ; AVX:       # BB#0:
17 ; AVX-NEXT:    vrcpss %xmm0, %xmm0, %xmm0
18 ; AVX-NEXT:    retq
19   %y = tail call <4 x float> @llvm.x86.sse.rcp.ss(<4 x float> %x)
20   %shuf = shufflevector <4 x float> %y, <4 x float> %x, <4 x i32> <i32 0, i32 5, i32 6, i32 7>
21   ret <4 x float> %shuf
22 }
23
24 define <4 x float> @recip_square_root(<4 x float> %x) {
25 ; SSE-LABEL: recip_square_root:
26 ; SSE:       # BB#0:
27 ; SSE-NEXT:    rsqrtss %xmm0, %xmm0
28 ; SSE-NEXT:    retq
29 ;
30 ; AVX-LABEL: recip_square_root:
31 ; AVX:       # BB#0:
32 ; AVX-NEXT:    vrsqrtss %xmm0, %xmm0, %xmm0
33 ; AVX-NEXT:    retq
34   %y = tail call <4 x float> @llvm.x86.sse.rsqrt.ss(<4 x float> %x)
35   %shuf = shufflevector <4 x float> %y, <4 x float> %x, <4 x i32> <i32 0, i32 5, i32 6, i32 7>
36   ret <4 x float> %shuf
37 }
38
39 define <4 x float> @square_root(<4 x float> %x) {
40 ; SSE-LABEL: square_root:
41 ; SSE:       # BB#0:
42 ; SSE-NEXT:    sqrtss %xmm0, %xmm0
43 ; SSE-NEXT:    retq
44 ;
45 ; AVX-LABEL: square_root:
46 ; AVX:       # BB#0:
47 ; AVX-NEXT:    vsqrtss %xmm0, %xmm0, %xmm0
48 ; AVX-NEXT:    retq
49   %y = tail call <4 x float> @llvm.x86.sse.sqrt.ss(<4 x float> %x)
50   %shuf = shufflevector <4 x float> %y, <4 x float> %x, <4 x i32> <i32 0, i32 5, i32 6, i32 7>
51   ret <4 x float> %shuf
52 }
53
54 define <2 x double> @square_root_double(<2 x double> %x) {
55 ; SSE-LABEL: square_root_double:
56 ; SSE:       # BB#0:
57 ; SSE-NEXT:    sqrtsd %xmm0, %xmm0
58 ; SSE-NEXT:    retq
59 ;
60 ; AVX-LABEL: square_root_double:
61 ; AVX:       # BB#0:
62 ; AVX-NEXT:    vsqrtsd %xmm0, %xmm0, %xmm0
63 ; AVX-NEXT:    retq
64   %y = tail call <2 x double> @llvm.x86.sse2.sqrt.sd(<2 x double> %x)
65   %shuf = shufflevector <2 x double> %y, <2 x double> %x, <2 x i32> <i32 0, i32 3>
66   ret <2 x double> %shuf
67 }
68
69 declare <4 x float> @llvm.x86.sse.rcp.ss(<4 x float>)
70 declare <4 x float> @llvm.x86.sse.rsqrt.ss(<4 x float>)
71 declare <4 x float> @llvm.x86.sse.sqrt.ss(<4 x float>)
72 declare <2 x double> @llvm.x86.sse2.sqrt.sd(<2 x double>)
73