1 ; NOTE: Assertions have been autogenerated by utils/update_llc_test_checks.py
2 ; RUN: llc < %s -fast-isel -mtriple=i386-unknown-unknown -mattr=+sse3 | FileCheck %s --check-prefixes=SSE,X86-SSE
3 ; RUN: llc < %s -fast-isel -mtriple=i386-unknown-unknown -mattr=+avx | FileCheck %s --check-prefixes=AVX,X86-AVX
4 ; RUN: llc < %s -fast-isel -mtriple=i386-unknown-unknown -mattr=+avx512f,+avx512bw,+avx512dq,+avx512vl | FileCheck %s --check-prefixes=AVX,X86-AVX
5 ; RUN: llc < %s -fast-isel -mtriple=x86_64-unknown-unknown -mattr=+sse3 | FileCheck %s --check-prefixes=SSE,X64-SSE
6 ; RUN: llc < %s -fast-isel -mtriple=x86_64-unknown-unknown -mattr=+avx | FileCheck %s --check-prefixes=AVX,X64-AVX
7 ; RUN: llc < %s -fast-isel -mtriple=x86_64-unknown-unknown -mattr=+avx512f,+avx512bw,+avx512dq,+avx512vl | FileCheck %s --check-prefixes=AVX,X64-AVX
9 ; NOTE: This should use IR equivalent to what is generated by clang/test/CodeGen/sse3-builtins.c
11 define <2 x double> @test_mm_addsub_pd(<2 x double> %a0, <2 x double> %a1) {
12 ; SSE-LABEL: test_mm_addsub_pd:
14 ; SSE-NEXT: addsubpd %xmm1, %xmm0
15 ; SSE-NEXT: ret{{[l|q]}}
17 ; AVX-LABEL: test_mm_addsub_pd:
19 ; AVX-NEXT: vaddsubpd %xmm1, %xmm0, %xmm0
20 ; AVX-NEXT: ret{{[l|q]}}
21 %res = call <2 x double> @llvm.x86.sse3.addsub.pd(<2 x double> %a0, <2 x double> %a1)
24 declare <2 x double> @llvm.x86.sse3.addsub.pd(<2 x double>, <2 x double>) nounwind readnone
26 define <4 x float> @test_mm_addsub_ps(<4 x float> %a0, <4 x float> %a1) {
27 ; SSE-LABEL: test_mm_addsub_ps:
29 ; SSE-NEXT: addsubps %xmm1, %xmm0
30 ; SSE-NEXT: ret{{[l|q]}}
32 ; AVX-LABEL: test_mm_addsub_ps:
34 ; AVX-NEXT: vaddsubps %xmm1, %xmm0, %xmm0
35 ; AVX-NEXT: ret{{[l|q]}}
36 %res = call <4 x float> @llvm.x86.sse3.addsub.ps(<4 x float> %a0, <4 x float> %a1)
39 declare <4 x float> @llvm.x86.sse3.addsub.ps(<4 x float>, <4 x float>) nounwind readnone
41 define <2 x double> @test_mm_hadd_pd(<2 x double> %a0, <2 x double> %a1) {
42 ; SSE-LABEL: test_mm_hadd_pd:
44 ; SSE-NEXT: haddpd %xmm1, %xmm0
45 ; SSE-NEXT: ret{{[l|q]}}
47 ; AVX-LABEL: test_mm_hadd_pd:
49 ; AVX-NEXT: vhaddpd %xmm1, %xmm0, %xmm0
50 ; AVX-NEXT: ret{{[l|q]}}
51 %res = call <2 x double> @llvm.x86.sse3.hadd.pd(<2 x double> %a0, <2 x double> %a1)
54 declare <2 x double> @llvm.x86.sse3.hadd.pd(<2 x double>, <2 x double>) nounwind readnone
56 define <4 x float> @test_mm_hadd_ps(<4 x float> %a0, <4 x float> %a1) {
57 ; SSE-LABEL: test_mm_hadd_ps:
59 ; SSE-NEXT: haddps %xmm1, %xmm0
60 ; SSE-NEXT: ret{{[l|q]}}
62 ; AVX-LABEL: test_mm_hadd_ps:
64 ; AVX-NEXT: vhaddps %xmm1, %xmm0, %xmm0
65 ; AVX-NEXT: ret{{[l|q]}}
66 %res = call <4 x float> @llvm.x86.sse3.hadd.ps(<4 x float> %a0, <4 x float> %a1)
69 declare <4 x float> @llvm.x86.sse3.hadd.ps(<4 x float>, <4 x float>) nounwind readnone
71 define <2 x double> @test_mm_hsub_pd(<2 x double> %a0, <2 x double> %a1) {
72 ; SSE-LABEL: test_mm_hsub_pd:
74 ; SSE-NEXT: hsubpd %xmm1, %xmm0
75 ; SSE-NEXT: ret{{[l|q]}}
77 ; AVX-LABEL: test_mm_hsub_pd:
79 ; AVX-NEXT: vhsubpd %xmm1, %xmm0, %xmm0
80 ; AVX-NEXT: ret{{[l|q]}}
81 %res = call <2 x double> @llvm.x86.sse3.hsub.pd(<2 x double> %a0, <2 x double> %a1)
84 declare <2 x double> @llvm.x86.sse3.hsub.pd(<2 x double>, <2 x double>) nounwind readnone
86 define <4 x float> @test_mm_hsub_ps(<4 x float> %a0, <4 x float> %a1) {
87 ; SSE-LABEL: test_mm_hsub_ps:
89 ; SSE-NEXT: hsubps %xmm1, %xmm0
90 ; SSE-NEXT: ret{{[l|q]}}
92 ; AVX-LABEL: test_mm_hsub_ps:
94 ; AVX-NEXT: vhsubps %xmm1, %xmm0, %xmm0
95 ; AVX-NEXT: ret{{[l|q]}}
96 %res = call <4 x float> @llvm.x86.sse3.hsub.ps(<4 x float> %a0, <4 x float> %a1)
99 declare <4 x float> @llvm.x86.sse3.hsub.ps(<4 x float>, <4 x float>) nounwind readnone
101 define <2 x i64> @test_mm_lddqu_si128(ptr %a0) {
102 ; X86-SSE-LABEL: test_mm_lddqu_si128:
104 ; X86-SSE-NEXT: movl {{[0-9]+}}(%esp), %eax
105 ; X86-SSE-NEXT: lddqu (%eax), %xmm0
108 ; X86-AVX-LABEL: test_mm_lddqu_si128:
110 ; X86-AVX-NEXT: movl {{[0-9]+}}(%esp), %eax
111 ; X86-AVX-NEXT: vlddqu (%eax), %xmm0
114 ; X64-SSE-LABEL: test_mm_lddqu_si128:
116 ; X64-SSE-NEXT: lddqu (%rdi), %xmm0
119 ; X64-AVX-LABEL: test_mm_lddqu_si128:
121 ; X64-AVX-NEXT: vlddqu (%rdi), %xmm0
123 %call = call <16 x i8> @llvm.x86.sse3.ldu.dq(ptr %a0)
124 %res = bitcast <16 x i8> %call to <2 x i64>
127 declare <16 x i8> @llvm.x86.sse3.ldu.dq(ptr) nounwind readonly
129 define <2 x double> @test_mm_loaddup_pd(ptr %a0) {
130 ; X86-SSE-LABEL: test_mm_loaddup_pd:
132 ; X86-SSE-NEXT: movl {{[0-9]+}}(%esp), %eax
133 ; X86-SSE-NEXT: movddup {{.*#+}} xmm0 = mem[0,0]
136 ; X86-AVX-LABEL: test_mm_loaddup_pd:
138 ; X86-AVX-NEXT: movl {{[0-9]+}}(%esp), %eax
139 ; X86-AVX-NEXT: vmovddup {{.*#+}} xmm0 = mem[0,0]
142 ; X64-SSE-LABEL: test_mm_loaddup_pd:
144 ; X64-SSE-NEXT: movddup {{.*#+}} xmm0 = mem[0,0]
147 ; X64-AVX-LABEL: test_mm_loaddup_pd:
149 ; X64-AVX-NEXT: vmovddup {{.*#+}} xmm0 = mem[0,0]
151 %ld = load double, ptr %a0
152 %res0 = insertelement <2 x double> undef, double %ld, i32 0
153 %res1 = insertelement <2 x double> %res0, double %ld, i32 1
154 ret <2 x double> %res1
157 define <2 x double> @test_mm_movedup_pd(<2 x double> %a0) {
158 ; SSE-LABEL: test_mm_movedup_pd:
160 ; SSE-NEXT: movddup {{.*#+}} xmm0 = xmm0[0,0]
161 ; SSE-NEXT: ret{{[l|q]}}
163 ; AVX-LABEL: test_mm_movedup_pd:
165 ; AVX-NEXT: vmovddup {{.*#+}} xmm0 = xmm0[0,0]
166 ; AVX-NEXT: ret{{[l|q]}}
167 %res = shufflevector <2 x double> %a0, <2 x double> %a0, <2 x i32> zeroinitializer
168 ret <2 x double> %res
171 define <4 x float> @test_mm_movehdup_ps(<4 x float> %a0) {
172 ; SSE-LABEL: test_mm_movehdup_ps:
174 ; SSE-NEXT: movshdup {{.*#+}} xmm0 = xmm0[1,1,3,3]
175 ; SSE-NEXT: ret{{[l|q]}}
177 ; AVX-LABEL: test_mm_movehdup_ps:
179 ; AVX-NEXT: vmovshdup {{.*#+}} xmm0 = xmm0[1,1,3,3]
180 ; AVX-NEXT: ret{{[l|q]}}
181 %res = shufflevector <4 x float> %a0, <4 x float> %a0, <4 x i32> <i32 1, i32 1, i32 3, i32 3>
185 define <4 x float> @test_mm_moveldup_ps(<4 x float> %a0) {
186 ; SSE-LABEL: test_mm_moveldup_ps:
188 ; SSE-NEXT: movsldup {{.*#+}} xmm0 = xmm0[0,0,2,2]
189 ; SSE-NEXT: ret{{[l|q]}}
191 ; AVX-LABEL: test_mm_moveldup_ps:
193 ; AVX-NEXT: vmovsldup {{.*#+}} xmm0 = xmm0[0,0,2,2]
194 ; AVX-NEXT: ret{{[l|q]}}
195 %res = shufflevector <4 x float> %a0, <4 x float> %a0, <4 x i32> <i32 0, i32 0, i32 2, i32 2>