1 // RUN: %clang_cc1 -flax-vector-conversions=none -ffreestanding %s -triple=x86_64-apple-darwin -target-feature +sse3 -emit-llvm -o - -Wall -Werror | FileCheck %s
2
3
4 #include <immintrin.h>
5
6 // NOTE: This should match the tests in llvm/test/CodeGen/X86/sse3-intrinsics-fast-isel.ll
7
test_mm_addsub_pd(__m128d A,__m128d B)8 __m128d test_mm_addsub_pd(__m128d A, __m128d B) {
9 // CHECK-LABEL: test_mm_addsub_pd
10 // CHECK: call <2 x double> @llvm.x86.sse3.addsub.pd(<2 x double> %{{.*}}, <2 x double> %{{.*}})
11 return _mm_addsub_pd(A, B);
12 }
13
test_mm_addsub_ps(__m128 A,__m128 B)14 __m128 test_mm_addsub_ps(__m128 A, __m128 B) {
15 // CHECK-LABEL: test_mm_addsub_ps
16 // CHECK: call <4 x float> @llvm.x86.sse3.addsub.ps(<4 x float> %{{.*}}, <4 x float> %{{.*}})
17 return _mm_addsub_ps(A, B);
18 }
19
test_mm_hadd_pd(__m128d A,__m128d B)20 __m128d test_mm_hadd_pd(__m128d A, __m128d B) {
21 // CHECK-LABEL: test_mm_hadd_pd
22 // CHECK: call <2 x double> @llvm.x86.sse3.hadd.pd(<2 x double> %{{.*}}, <2 x double> %{{.*}})
23 return _mm_hadd_pd(A, B);
24 }
25
test_mm_hadd_ps(__m128 A,__m128 B)26 __m128 test_mm_hadd_ps(__m128 A, __m128 B) {
27 // CHECK-LABEL: test_mm_hadd_ps
28 // CHECK: call <4 x float> @llvm.x86.sse3.hadd.ps(<4 x float> %{{.*}}, <4 x float> %{{.*}})
29 return _mm_hadd_ps(A, B);
30 }
31
test_mm_hsub_pd(__m128d A,__m128d B)32 __m128d test_mm_hsub_pd(__m128d A, __m128d B) {
33 // CHECK-LABEL: test_mm_hsub_pd
34 // CHECK: call <2 x double> @llvm.x86.sse3.hsub.pd(<2 x double> %{{.*}}, <2 x double> %{{.*}})
35 return _mm_hsub_pd(A, B);
36 }
37
test_mm_hsub_ps(__m128 A,__m128 B)38 __m128 test_mm_hsub_ps(__m128 A, __m128 B) {
39 // CHECK-LABEL: test_mm_hsub_ps
40 // CHECK: call <4 x float> @llvm.x86.sse3.hsub.ps(<4 x float> %{{.*}}, <4 x float> %{{.*}})
41 return _mm_hsub_ps(A, B);
42 }
43
test_mm_lddqu_si128(__m128i const * P)44 __m128i test_mm_lddqu_si128(__m128i const* P) {
45 // CHECK-LABEL: test_mm_lddqu_si128
46 // CHECK: call <16 x i8> @llvm.x86.sse3.ldu.dq(i8* %{{.*}})
47 return _mm_lddqu_si128(P);
48 }
49
test_mm_loaddup_pd(double const * P)50 __m128d test_mm_loaddup_pd(double const* P) {
51 // CHECK-LABEL: test_mm_loaddup_pd
52 // CHECK: load double*
53 // CHECK: insertelement <2 x double> undef, double %{{.*}}, i32 0
54 // CHECK: insertelement <2 x double> %{{.*}}, double %{{.*}}, i32 1
55 return _mm_loaddup_pd(P);
56 }
57
test_mm_movedup_pd(__m128d A)58 __m128d test_mm_movedup_pd(__m128d A) {
59 // CHECK-LABEL: test_mm_movedup_pd
60 // CHECK: shufflevector <2 x double> %{{.*}}, <2 x double> %{{.*}}, <2 x i32> zeroinitializer
61 return _mm_movedup_pd(A);
62 }
63
test_mm_movehdup_ps(__m128 A)64 __m128 test_mm_movehdup_ps(__m128 A) {
65 // CHECK-LABEL: test_mm_movehdup_ps
66 // CHECK: shufflevector <4 x float> %{{.*}}, <4 x float> %{{.*}}, <4 x i32> <i32 1, i32 1, i32 3, i32 3>
67 return _mm_movehdup_ps(A);
68 }
69
test_mm_moveldup_ps(__m128 A)70 __m128 test_mm_moveldup_ps(__m128 A) {
71 // CHECK-LABEL: test_mm_moveldup_ps
72 // CHECK: shufflevector <4 x float> %{{.*}}, <4 x float> %{{.*}}, <4 x i32> <i32 0, i32 0, i32 2, i32 2>
73 return _mm_moveldup_ps(A);
74 }
75