1 ; RUN: llc -mtriple=x86_64-unknown-unknown -mattr=+sse2 < %s | FileCheck %s --check-prefix=SSE
2 ; RUN: llc -mtriple=x86_64-unknown-unknown -mattr=+avx < %s | FileCheck %s --check-prefix=AVX
4 ; Verify that we're folding the load into the math instruction.
6 define float @rcpss(float* %a) {
9 ; SSE-NEXT: rcpss (%rdi), %xmm0
14 ; AVX-NEXT: vrcpss (%rdi), %xmm0, %xmm0
16 %ld = load float, float* %a
17 %ins = insertelement <4 x float> undef, float %ld, i32 0
18 %res = tail call <4 x float> @llvm.x86.sse.rcp.ss(<4 x float> %ins)
19 %ext = extractelement <4 x float> %res, i32 0
23 define float @rsqrtss(float* %a) {
26 ; SSE-NEXT: rsqrtss (%rdi), %xmm0
31 ; AVX-NEXT: vrsqrtss (%rdi), %xmm0, %xmm0
33 %ld = load float, float* %a
34 %ins = insertelement <4 x float> undef, float %ld, i32 0
35 %res = tail call <4 x float> @llvm.x86.sse.rsqrt.ss(<4 x float> %ins)
36 %ext = extractelement <4 x float> %res, i32 0
40 define float @sqrtss(float* %a) {
43 ; SSE-NEXT: sqrtss (%rdi), %xmm0
48 ; AVX-NEXT: vsqrtss (%rdi), %xmm0, %xmm0
50 %ld = load float, float* %a
51 %ins = insertelement <4 x float> undef, float %ld, i32 0
52 %res = tail call <4 x float> @llvm.x86.sse.sqrt.ss(<4 x float> %ins)
53 %ext = extractelement <4 x float> %res, i32 0
57 define double @sqrtsd(double* %a) {
60 ; SSE-NEXT: sqrtsd (%rdi), %xmm0
65 ; AVX-NEXT: vsqrtsd (%rdi), %xmm0, %xmm0
67 %ld = load double, double* %a
68 %ins = insertelement <2 x double> undef, double %ld, i32 0
69 %res = tail call <2 x double> @llvm.x86.sse2.sqrt.sd(<2 x double> %ins)
70 %ext = extractelement <2 x double> %res, i32 0
75 declare <4 x float> @llvm.x86.sse.rcp.ss(<4 x float>) nounwind readnone
76 declare <4 x float> @llvm.x86.sse.rsqrt.ss(<4 x float>) nounwind readnone
77 declare <4 x float> @llvm.x86.sse.sqrt.ss(<4 x float>) nounwind readnone
78 declare <2 x double> @llvm.x86.sse2.sqrt.sd(<2 x double>) nounwind readnone