[X86] Update test/CodeGen/X86/avg.ll with the help of update_llc_test_checks.py....
[oota-llvm.git] / test / CodeGen / X86 / fold-load-unops.ll
1 ; NOTE: Assertions have been autogenerated by utils/update_llc_test_checks.py
2 ; RUN: llc -mtriple=x86_64-unknown-unknown -mattr=+sse2 < %s | FileCheck %s --check-prefix=SSE
3 ; RUN: llc -mtriple=x86_64-unknown-unknown -mattr=+avx < %s | FileCheck %s --check-prefix=AVX
4
5 ; Verify that we're folding the load into the math instruction.
6
7 define float @rcpss(float* %a) {
8 ; SSE-LABEL: rcpss:
9 ; SSE:       # BB#0:
10 ; SSE-NEXT:    rcpss (%rdi), %xmm0
11 ; SSE-NEXT:    retq
12 ;
13 ; AVX-LABEL: rcpss:
14 ; AVX:       # BB#0:
15 ; AVX-NEXT:    vrcpss (%rdi), %xmm0, %xmm0
16 ; AVX-NEXT:    retq
17     %ld = load float, float* %a
18     %ins = insertelement <4 x float> undef, float %ld, i32 0
19     %res = tail call <4 x float> @llvm.x86.sse.rcp.ss(<4 x float> %ins)
20     %ext = extractelement <4 x float> %res, i32 0
21     ret float %ext
22 }
23
24 define float @rsqrtss(float* %a) {
25 ; SSE-LABEL: rsqrtss:
26 ; SSE:       # BB#0:
27 ; SSE-NEXT:    rsqrtss (%rdi), %xmm0
28 ; SSE-NEXT:    retq
29 ;
30 ; AVX-LABEL: rsqrtss:
31 ; AVX:       # BB#0:
32 ; AVX-NEXT:    vrsqrtss (%rdi), %xmm0, %xmm0
33 ; AVX-NEXT:    retq
34     %ld = load float, float* %a
35     %ins = insertelement <4 x float> undef, float %ld, i32 0
36     %res = tail call <4 x float> @llvm.x86.sse.rsqrt.ss(<4 x float> %ins)
37     %ext = extractelement <4 x float> %res, i32 0
38     ret float %ext
39 }
40
41 define float @sqrtss(float* %a) {
42 ; SSE-LABEL: sqrtss:
43 ; SSE:       # BB#0:
44 ; SSE-NEXT:    sqrtss (%rdi), %xmm0
45 ; SSE-NEXT:    retq
46 ;
47 ; AVX-LABEL: sqrtss:
48 ; AVX:       # BB#0:
49 ; AVX-NEXT:    vsqrtss (%rdi), %xmm0, %xmm0
50 ; AVX-NEXT:    retq
51     %ld = load float, float* %a
52     %ins = insertelement <4 x float> undef, float %ld, i32 0
53     %res = tail call <4 x float> @llvm.x86.sse.sqrt.ss(<4 x float> %ins)
54     %ext = extractelement <4 x float> %res, i32 0
55     ret float %ext
56 }
57
58 define double @sqrtsd(double* %a) {
59 ; SSE-LABEL: sqrtsd:
60 ; SSE:       # BB#0:
61 ; SSE-NEXT:    sqrtsd (%rdi), %xmm0
62 ; SSE-NEXT:    retq
63 ;
64 ; AVX-LABEL: sqrtsd:
65 ; AVX:       # BB#0:
66 ; AVX-NEXT:    vsqrtsd (%rdi), %xmm0, %xmm0
67 ; AVX-NEXT:    retq
68     %ld = load double, double* %a
69     %ins = insertelement <2 x double> undef, double %ld, i32 0
70     %res = tail call <2 x double> @llvm.x86.sse2.sqrt.sd(<2 x double> %ins)
71     %ext = extractelement <2 x double> %res, i32 0
72     ret double %ext
73 }
74
75
76 declare <4 x float> @llvm.x86.sse.rcp.ss(<4 x float>) nounwind readnone
77 declare <4 x float> @llvm.x86.sse.rsqrt.ss(<4 x float>) nounwind readnone
78 declare <4 x float> @llvm.x86.sse.sqrt.ss(<4 x float>) nounwind readnone
79 declare <2 x double> @llvm.x86.sse2.sqrt.sd(<2 x double>) nounwind readnone
80