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
5 ; PR21507 - https://llvm.org/bugs/show_bug.cgi?id=21507
6 ; Each function should be a single math op; no extra moves.
9 define <4 x float> @recip(<4 x float> %x) {
12 ; SSE-NEXT: rcpss %xmm0, %xmm0
17 ; AVX-NEXT: vrcpss %xmm0, %xmm0, %xmm0
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>
24 define <4 x float> @recip_square_root(<4 x float> %x) {
25 ; SSE-LABEL: recip_square_root:
27 ; SSE-NEXT: rsqrtss %xmm0, %xmm0
30 ; AVX-LABEL: recip_square_root:
32 ; AVX-NEXT: vrsqrtss %xmm0, %xmm0, %xmm0
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>
39 define <4 x float> @square_root(<4 x float> %x) {
40 ; SSE-LABEL: square_root:
42 ; SSE-NEXT: sqrtss %xmm0, %xmm0
45 ; AVX-LABEL: square_root:
47 ; AVX-NEXT: vsqrtss %xmm0, %xmm0, %xmm0
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>
54 define <2 x double> @square_root_double(<2 x double> %x) {
55 ; SSE-LABEL: square_root_double:
57 ; SSE-NEXT: sqrtsd %xmm0, %xmm0
60 ; AVX-LABEL: square_root_double:
62 ; AVX-NEXT: vsqrtsd %xmm0, %xmm0, %xmm0
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
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>)