blob: 46a7bbbb91e27e3d567f7a4bd5067e6422889185 [file] [log] [blame]
Elad Cohenb107a222016-09-28 11:59:09 +00001// RUN: %clang_cc1 -ffreestanding %s -triple=x86_64-apple-darwin -target-feature +sse3 -emit-llvm -o - -Wall -Werror | FileCheck %s
Simon Pilgrim8391ac72015-09-06 14:45:13 +00002
Simon Pilgrim8391ac72015-09-06 14:45:13 +00003
4#include <x86intrin.h>
5
Simon Pilgrim05e07832016-03-10 14:46:49 +00006// NOTE: This should match the tests in llvm/test/CodeGen/X86/sse3-intrinsics-fast-isel.ll
7
Simon Pilgrim8391ac72015-09-06 14:45:13 +00008__m128d test_mm_addsub_pd(__m128d A, __m128d B) {
9 // CHECK-LABEL: test_mm_addsub_pd
Simon Pilgrim05e07832016-03-10 14:46:49 +000010 // CHECK: call <2 x double> @llvm.x86.sse3.addsub.pd(<2 x double> %{{.*}}, <2 x double> %{{.*}})
Simon Pilgrim8391ac72015-09-06 14:45:13 +000011 return _mm_addsub_pd(A, B);
12}
13
14__m128 test_mm_addsub_ps(__m128 A, __m128 B) {
15 // CHECK-LABEL: test_mm_addsub_ps
Simon Pilgrim05e07832016-03-10 14:46:49 +000016 // CHECK: call <4 x float> @llvm.x86.sse3.addsub.ps(<4 x float> %{{.*}}, <4 x float> %{{.*}})
Simon Pilgrim8391ac72015-09-06 14:45:13 +000017 return _mm_addsub_ps(A, B);
18}
19
20__m128d test_mm_hadd_pd(__m128d A, __m128d B) {
21 // CHECK-LABEL: test_mm_hadd_pd
Simon Pilgrim05e07832016-03-10 14:46:49 +000022 // CHECK: call <2 x double> @llvm.x86.sse3.hadd.pd(<2 x double> %{{.*}}, <2 x double> %{{.*}})
Simon Pilgrim8391ac72015-09-06 14:45:13 +000023 return _mm_hadd_pd(A, B);
24}
25
26__m128 test_mm_hadd_ps(__m128 A, __m128 B) {
27 // CHECK-LABEL: test_mm_hadd_ps
Simon Pilgrim05e07832016-03-10 14:46:49 +000028 // CHECK: call <4 x float> @llvm.x86.sse3.hadd.ps(<4 x float> %{{.*}}, <4 x float> %{{.*}})
Simon Pilgrim8391ac72015-09-06 14:45:13 +000029 return _mm_hadd_ps(A, B);
30}
31
32__m128d test_mm_hsub_pd(__m128d A, __m128d B) {
33 // CHECK-LABEL: test_mm_hsub_pd
Simon Pilgrim05e07832016-03-10 14:46:49 +000034 // CHECK: call <2 x double> @llvm.x86.sse3.hsub.pd(<2 x double> %{{.*}}, <2 x double> %{{.*}})
Simon Pilgrim8391ac72015-09-06 14:45:13 +000035 return _mm_hsub_pd(A, B);
36}
37
38__m128 test_mm_hsub_ps(__m128 A, __m128 B) {
39 // CHECK-LABEL: test_mm_hsub_ps
Simon Pilgrim05e07832016-03-10 14:46:49 +000040 // CHECK: call <4 x float> @llvm.x86.sse3.hsub.ps(<4 x float> %{{.*}}, <4 x float> %{{.*}})
Simon Pilgrim8391ac72015-09-06 14:45:13 +000041 return _mm_hsub_ps(A, B);
42}
43
44__m128i test_mm_lddqu_si128(__m128i const* P) {
45 // CHECK-LABEL: test_mm_lddqu_si128
Simon Pilgrim05e07832016-03-10 14:46:49 +000046 // CHECK: call <16 x i8> @llvm.x86.sse3.ldu.dq(i8* %{{.*}})
Simon Pilgrim8391ac72015-09-06 14:45:13 +000047 return _mm_lddqu_si128(P);
48}
49
50__m128d test_mm_loaddup_pd(double const* P) {
51 // CHECK-LABEL: test_mm_loaddup_pd
52 // CHECK: load double*
Simon Pilgrim7e148a92016-05-18 13:17:39 +000053 // CHECK: insertelement <2 x double> undef, double %{{.*}}, i32 0
54 // CHECK: insertelement <2 x double> %{{.*}}, double %{{.*}}, i32 1
Simon Pilgrim8391ac72015-09-06 14:45:13 +000055 return _mm_loaddup_pd(P);
56}
57
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
Simon Pilgrim8391ac72015-09-06 14:45:13 +000061 return _mm_movedup_pd(A);
62}
63
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>
Simon Pilgrim8391ac72015-09-06 14:45:13 +000067 return _mm_movehdup_ps(A);
68}
69
Simon Pilgrimdfd2cf32015-12-05 11:08:51 +000070__m128 test_mm_moveldup_ps(__m128 A) {
71 // CHECK-LABEL: test_mm_moveldup_ps
Simon Pilgrim8391ac72015-09-06 14:45:13 +000072 // CHECK: shufflevector <4 x float> %{{.*}}, <4 x float> %{{.*}}, <4 x i32> <i32 0, i32 0, i32 2, i32 2>
Simon Pilgrim8391ac72015-09-06 14:45:13 +000073 return _mm_moveldup_ps(A);
74}