| 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 |
| 5 |
|
| 6 |
// RUN: %clang_cc1 -x c -flax-vector-conversions=none -ffreestanding %s -triple=x86_64-apple-darwin -target-feature +sse3 -emit-llvm -o - -Wall -Werror -fexperimental-new-constant-interpreter | FileCheck %s |
| 7 |
// RUN: %clang_cc1 -x c -flax-vector-conversions=none -ffreestanding %s -triple=i386-apple-darwin -target-feature +sse3 -emit-llvm -o - -Wall -Werror -fexperimental-new-constant-interpreter | FileCheck %s |
| 8 |
// RUN: %clang_cc1 -x c++ -flax-vector-conversions=none -ffreestanding %s -triple=x86_64-apple-darwin -target-feature +sse3 -emit-llvm -o - -Wall -Werror -fexperimental-new-constant-interpreter | FileCheck %s |
| 9 |
// RUN: %clang_cc1 -x c++ -flax-vector-conversions=none -ffreestanding %s -triple=i386-apple-darwin -target-feature +sse3 -emit-llvm -o - -Wall -Werror -fexperimental-new-constant-interpreter | FileCheck %s |
| 10 |
|
| 11 |
|
| 12 |
#include <immintrin.h> |
| 13 |
#include "builtin_test_helpers.h" |
| 14 |
|
| 15 |
// NOTE: This should match the tests in llvm/test/CodeGen/X86/sse3-intrinsics-fast-isel.ll |
| 16 |
|
| 17 |
__m128d test_mm_addsub_pd(__m128d A, __m128d B) { |
| 18 |
// CHECK-LABEL: test_mm_addsub_pd |
| 19 |
// CHECK: call {{.*}}<2 x double> @llvm.x86.sse3.addsub.pd(<2 x double> %{{.*}}, <2 x double> %{{.*}}) |
| 20 |
return _mm_addsub_pd(A, B); |
| 21 |
} |
| 22 |
TEST_CONSTEXPR(match_m128d(_mm_addsub_pd((__m128d){+2.0, +2.0}, (__m128d){+1.0, +2.0}), +1.0, +4.0)); |
| 23 |
|
| 24 |
__m128 test_mm_addsub_ps(__m128 A, __m128 B) { |
| 25 |
// CHECK-LABEL: test_mm_addsub_ps |
| 26 |
// CHECK: call {{.*}}<4 x float> @llvm.x86.sse3.addsub.ps(<4 x float> %{{.*}}, <4 x float> %{{.*}}) |
| 27 |
return _mm_addsub_ps(A, B); |
| 28 |
} |
| 29 |
TEST_CONSTEXPR(match_m128(_mm_addsub_ps((__m128){+3.0f, +4.0f, +5.0f, +6.0f}, (__m128){+1.0f, +2.0f, +3.0f, +4.0f}), +2.0f, +6.0f, +2.0f, +10.0f)); |
| 30 |
|
| 31 |
__m128d test_mm_hadd_pd(__m128d A, __m128d B) { |
| 32 |
// CHECK-LABEL: test_mm_hadd_pd |
| 33 |
// CHECK: call {{.*}}<2 x double> @llvm.x86.sse3.hadd.pd(<2 x double> %{{.*}}, <2 x double> %{{.*}}) |
| 34 |
return _mm_hadd_pd(A, B); |
| 35 |
} |
| 36 |
TEST_CONSTEXPR(match_m128d(_mm_hadd_pd((__m128d){+1.0, +2.0}, (__m128d){+3.0, +4.0}), +3.0, +7.0)); |
| 37 |
|
| 38 |
__m128 test_mm_hadd_ps(__m128 A, __m128 B) { |
| 39 |
// CHECK-LABEL: test_mm_hadd_ps |
| 40 |
// CHECK: call {{.*}}<4 x float> @llvm.x86.sse3.hadd.ps(<4 x float> %{{.*}}, <4 x float> %{{.*}}) |
| 41 |
return _mm_hadd_ps(A, B); |
| 42 |
} |
| 43 |
TEST_CONSTEXPR(match_m128(_mm_hadd_ps((__m128){+1.0f, +2.0f, +3.0f, +4.0f}, (__m128){+5.0f,+6.0f,+7.0f,+8.0f}), +3.0f, +7.0f, +11.0f, +15.0f)); |
| 44 |
|
| 45 |
__m128d test_mm_hsub_pd(__m128d A, __m128d B) { |
| 46 |
// CHECK-LABEL: test_mm_hsub_pd |
| 47 |
// CHECK: call {{.*}}<2 x double> @llvm.x86.sse3.hsub.pd(<2 x double> %{{.*}}, <2 x double> %{{.*}}) |
| 48 |
return _mm_hsub_pd(A, B); |
| 49 |
} |
| 50 |
TEST_CONSTEXPR(match_m128d(_mm_hsub_pd((__m128d){+1.0, +2.0}, (__m128d){+4.0, +3.0}), -1.0, +1.0)); |
| 51 |
|
| 52 |
__m128 test_mm_hsub_ps(__m128 A, __m128 B) { |
| 53 |
// CHECK-LABEL: test_mm_hsub_ps |
| 54 |
// CHECK: call {{.*}}<4 x float> @llvm.x86.sse3.hsub.ps(<4 x float> %{{.*}}, <4 x float> %{{.*}}) |
| 55 |
return _mm_hsub_ps(A, B); |
| 56 |
} |
| 57 |
TEST_CONSTEXPR(match_m128(_mm_hsub_ps((__m128){+1.0f, +2.0f, +4.0f, +3.0f}, (__m128){+5.0f,+7.0f,+10.0f,+8.0f}), -1.0f, +1.0f, -2.0f, +2.0f)); |
| 58 |
|
| 59 |
__m128i test_mm_lddqu_si128(__m128i const* P) { |
| 60 |
// CHECK-LABEL: test_mm_lddqu_si128 |
| 61 |
// CHECK: call <16 x i8> @llvm.x86.sse3.ldu.dq(ptr %{{.*}}) |
| 62 |
return _mm_lddqu_si128(P); |
| 63 |
} |
| 64 |
|
| 65 |
__m128d test_mm_loaddup_pd(double const* P) { |
| 66 |
// CHECK-LABEL: test_mm_loaddup_pd |
| 67 |
// CHECK: load ptr |
| 68 |
// CHECK: insertelement <2 x double> poison, double %{{.*}}, i32 0 |
| 69 |
// CHECK: insertelement <2 x double> %{{.*}}, double %{{.*}}, i32 1 |
| 70 |
return _mm_loaddup_pd(P); |
| 71 |
} |
| 72 |
|
| 73 |
__m128d test_mm_movedup_pd(__m128d A) { |
| 74 |
// CHECK-LABEL: test_mm_movedup_pd |
| 75 |
// CHECK: shufflevector <2 x double> %{{.*}}, <2 x double> %{{.*}}, <2 x i32> zeroinitializer |
| 76 |
return _mm_movedup_pd(A); |
| 77 |
} |
| 78 |
TEST_CONSTEXPR(match_m128d(_mm_movedup_pd((__m128d){+7.0, -7.0}), +7.0, +7.0)); |
| 79 |
|
| 80 |
__m128 test_mm_movehdup_ps(__m128 A) { |
| 81 |
// CHECK-LABEL: test_mm_movehdup_ps |
| 82 |
// CHECK: shufflevector <4 x float> %{{.*}}, <4 x float> %{{.*}}, <4 x i32> <i32 1, i32 1, i32 3, i32 3> |
| 83 |
return _mm_movehdup_ps(A); |
| 84 |
} |
| 85 |
TEST_CONSTEXPR(match_m128(_mm_movehdup_ps((__m128){+1.0f,-1.0f,+2.0f,+4.0f}), -1.0f, -1.0f, +4.0f, +4.0f)); |
| 86 |
|
| 87 |
__m128 test_mm_moveldup_ps(__m128 A) { |
| 88 |
// CHECK-LABEL: test_mm_moveldup_ps |
| 89 |
// CHECK: shufflevector <4 x float> %{{.*}}, <4 x float> %{{.*}}, <4 x i32> <i32 0, i32 0, i32 2, i32 2> |
| 90 |
return _mm_moveldup_ps(A); |
| 91 |
} |
| 92 |
TEST_CONSTEXPR(match_m128(_mm_moveldup_ps((__m128){+1.0f,-1.0f,+2.0f,+4.0f}), +1.0f, +1.0f, +2.0f, +2.0f)); |