[LLVM][IR] Use splat syntax when printing ConstantExpr based splats. (#116856)
[llvm-project.git] / clang / test / CodeGen / X86 / sse3-builtins.c
blobd47c19b882cd1efb4894659249b2368f04cb4695
1 // RUN: %clang_cc1 -x c -flax-vector-conversions=none -ffreestanding %s -triple=x86_64-apple-darwin -target-feature +sse3 -emit-llvm -o - -Wall -Werror | FileCheck %s
2 // RUN: %clang_cc1 -x c -flax-vector-conversions=none -ffreestanding %s -triple=i386-apple-darwin -target-feature +sse3 -emit-llvm -o - -Wall -Werror | FileCheck %s
3 // RUN: %clang_cc1 -x c++ -flax-vector-conversions=none -ffreestanding %s -triple=x86_64-apple-darwin -target-feature +sse3 -emit-llvm -o - -Wall -Werror | FileCheck %s
4 // RUN: %clang_cc1 -x c++ -flax-vector-conversions=none -ffreestanding %s -triple=i386-apple-darwin -target-feature +sse3 -emit-llvm -o - -Wall -Werror | FileCheck %s
7 #include <immintrin.h>
8 #include "builtin_test_helpers.h"
10 // NOTE: This should match the tests in llvm/test/CodeGen/X86/sse3-intrinsics-fast-isel.ll
12 __m128d test_mm_addsub_pd(__m128d A, __m128d B) {
13 // CHECK-LABEL: test_mm_addsub_pd
14 // CHECK: call {{.*}}<2 x double> @llvm.x86.sse3.addsub.pd(<2 x double> %{{.*}}, <2 x double> %{{.*}})
15 return _mm_addsub_pd(A, B);
18 __m128 test_mm_addsub_ps(__m128 A, __m128 B) {
19 // CHECK-LABEL: test_mm_addsub_ps
20 // CHECK: call {{.*}}<4 x float> @llvm.x86.sse3.addsub.ps(<4 x float> %{{.*}}, <4 x float> %{{.*}})
21 return _mm_addsub_ps(A, B);
24 __m128d test_mm_hadd_pd(__m128d A, __m128d B) {
25 // CHECK-LABEL: test_mm_hadd_pd
26 // CHECK: call {{.*}}<2 x double> @llvm.x86.sse3.hadd.pd(<2 x double> %{{.*}}, <2 x double> %{{.*}})
27 return _mm_hadd_pd(A, B);
30 __m128 test_mm_hadd_ps(__m128 A, __m128 B) {
31 // CHECK-LABEL: test_mm_hadd_ps
32 // CHECK: call {{.*}}<4 x float> @llvm.x86.sse3.hadd.ps(<4 x float> %{{.*}}, <4 x float> %{{.*}})
33 return _mm_hadd_ps(A, B);
36 __m128d test_mm_hsub_pd(__m128d A, __m128d B) {
37 // CHECK-LABEL: test_mm_hsub_pd
38 // CHECK: call {{.*}}<2 x double> @llvm.x86.sse3.hsub.pd(<2 x double> %{{.*}}, <2 x double> %{{.*}})
39 return _mm_hsub_pd(A, B);
42 __m128 test_mm_hsub_ps(__m128 A, __m128 B) {
43 // CHECK-LABEL: test_mm_hsub_ps
44 // CHECK: call {{.*}}<4 x float> @llvm.x86.sse3.hsub.ps(<4 x float> %{{.*}}, <4 x float> %{{.*}})
45 return _mm_hsub_ps(A, B);
48 __m128i test_mm_lddqu_si128(__m128i const* P) {
49 // CHECK-LABEL: test_mm_lddqu_si128
50 // CHECK: call <16 x i8> @llvm.x86.sse3.ldu.dq(ptr %{{.*}})
51 return _mm_lddqu_si128(P);
54 __m128d test_mm_loaddup_pd(double const* P) {
55 // CHECK-LABEL: test_mm_loaddup_pd
56 // CHECK: load ptr
57 // CHECK: insertelement <2 x double> poison, double %{{.*}}, i32 0
58 // CHECK: insertelement <2 x double> %{{.*}}, double %{{.*}}, i32 1
59 return _mm_loaddup_pd(P);
62 __m128d test_mm_movedup_pd(__m128d A) {
63 // CHECK-LABEL: test_mm_movedup_pd
64 // CHECK: shufflevector <2 x double> %{{.*}}, <2 x double> %{{.*}}, <2 x i32> zeroinitializer
65 return _mm_movedup_pd(A);
67 TEST_CONSTEXPR(match_m128d(_mm_movedup_pd((__m128d){+7.0, -7.0}), +7.0, +7.0));
69 __m128 test_mm_movehdup_ps(__m128 A) {
70 // CHECK-LABEL: test_mm_movehdup_ps
71 // CHECK: shufflevector <4 x float> %{{.*}}, <4 x float> %{{.*}}, <4 x i32> <i32 1, i32 1, i32 3, i32 3>
72 return _mm_movehdup_ps(A);
74 TEST_CONSTEXPR(match_m128(_mm_movehdup_ps((__m128){+1.0f,-1.0f,+2.0f,+4.0f}), -1.0f, -1.0f, +4.0f, +4.0f));
76 __m128 test_mm_moveldup_ps(__m128 A) {
77 // CHECK-LABEL: test_mm_moveldup_ps
78 // CHECK: shufflevector <4 x float> %{{.*}}, <4 x float> %{{.*}}, <4 x i32> <i32 0, i32 0, i32 2, i32 2>
79 return _mm_moveldup_ps(A);
81 TEST_CONSTEXPR(match_m128(_mm_moveldup_ps((__m128){+1.0f,-1.0f,+2.0f,+4.0f}), +1.0f, +1.0f, +2.0f, +2.0f));