1*f4a2713aSLionel Sambuc // RUN: %clang_cc1 %s -O3 -triple=x86_64-apple-darwin -target-feature +avx -emit-llvm -o - | FileCheck %s
2*f4a2713aSLionel Sambuc
3*f4a2713aSLionel Sambuc // Don't include mm_malloc.h, it's system specific.
4*f4a2713aSLionel Sambuc #define __MM_MALLOC_H
5*f4a2713aSLionel Sambuc
6*f4a2713aSLionel Sambuc #include <immintrin.h>
7*f4a2713aSLionel Sambuc
8*f4a2713aSLionel Sambuc //
9*f4a2713aSLionel Sambuc // Test LLVM IR codegen of cmpXY instructions
10*f4a2713aSLionel Sambuc //
11*f4a2713aSLionel Sambuc
test_cmp_pd(__m128d a,__m128d b)12*f4a2713aSLionel Sambuc __m128d test_cmp_pd(__m128d a, __m128d b) {
13*f4a2713aSLionel Sambuc // Expects that the third argument in LLVM IR is immediate expression
14*f4a2713aSLionel Sambuc // CHECK: @llvm.x86.sse2.cmp.pd({{.*}}, i8 13)
15*f4a2713aSLionel Sambuc return _mm_cmp_pd(a, b, _CMP_GE_OS);
16*f4a2713aSLionel Sambuc }
17*f4a2713aSLionel Sambuc
test_cmp_ps(__m128 a,__m128 b)18*f4a2713aSLionel Sambuc __m128d test_cmp_ps(__m128 a, __m128 b) {
19*f4a2713aSLionel Sambuc // Expects that the third argument in LLVM IR is immediate expression
20*f4a2713aSLionel Sambuc // CHECK: @llvm.x86.sse.cmp.ps({{.*}}, i8 13)
21*f4a2713aSLionel Sambuc return _mm_cmp_ps(a, b, _CMP_GE_OS);
22*f4a2713aSLionel Sambuc }
23*f4a2713aSLionel Sambuc
test_cmp_pd256(__m256d a,__m256d b)24*f4a2713aSLionel Sambuc __m256d test_cmp_pd256(__m256d a, __m256d b) {
25*f4a2713aSLionel Sambuc // Expects that the third argument in LLVM IR is immediate expression
26*f4a2713aSLionel Sambuc // CHECK: @llvm.x86.avx.cmp.pd.256({{.*}}, i8 13)
27*f4a2713aSLionel Sambuc return _mm256_cmp_pd(a, b, _CMP_GE_OS);
28*f4a2713aSLionel Sambuc }
29*f4a2713aSLionel Sambuc
test_cmp_ps256(__m256 a,__m256 b)30*f4a2713aSLionel Sambuc __m256d test_cmp_ps256(__m256 a, __m256 b) {
31*f4a2713aSLionel Sambuc // Expects that the third argument in LLVM IR is immediate expression
32*f4a2713aSLionel Sambuc // CHECK: @llvm.x86.avx.cmp.ps.256({{.*}}, i8 13)
33*f4a2713aSLionel Sambuc return _mm256_cmp_ps(a, b, _CMP_GE_OS);
34*f4a2713aSLionel Sambuc }
35*f4a2713aSLionel Sambuc
test_cmp_sd(__m128d a,__m128d b)36*f4a2713aSLionel Sambuc __m128d test_cmp_sd(__m128d a, __m128d b) {
37*f4a2713aSLionel Sambuc // Expects that the third argument in LLVM IR is immediate expression
38*f4a2713aSLionel Sambuc // CHECK: @llvm.x86.sse2.cmp.sd({{.*}}, i8 13)
39*f4a2713aSLionel Sambuc return _mm_cmp_sd(a, b, _CMP_GE_OS);
40*f4a2713aSLionel Sambuc }
41*f4a2713aSLionel Sambuc
test_cmp_ss(__m128 a,__m128 b)42*f4a2713aSLionel Sambuc __m128d test_cmp_ss(__m128 a, __m128 b) {
43*f4a2713aSLionel Sambuc // Expects that the third argument in LLVM IR is immediate expression
44*f4a2713aSLionel Sambuc // CHECK: @llvm.x86.sse.cmp.ss({{.*}}, i8 13)
45*f4a2713aSLionel Sambuc return _mm_cmp_ss(a, b, _CMP_GE_OS);
46*f4a2713aSLionel Sambuc }
47*f4a2713aSLionel Sambuc
test_cmpgt_ss(__m128 a,__m128 b)48*f4a2713aSLionel Sambuc __m128 test_cmpgt_ss(__m128 a, __m128 b) {
49*f4a2713aSLionel Sambuc // CHECK: @llvm.x86.sse.cmp.ss({{.*}}, i8 1)
50*f4a2713aSLionel Sambuc // CHECK: shufflevector <{{.*}}, <4 x i32> <i32 4, i32 1, i32 2, i32 3>
51*f4a2713aSLionel Sambuc return _mm_cmpgt_ss(a, b);
52*f4a2713aSLionel Sambuc }
53*f4a2713aSLionel Sambuc
test_cmpge_ss(__m128 a,__m128 b)54*f4a2713aSLionel Sambuc __m128 test_cmpge_ss(__m128 a, __m128 b) {
55*f4a2713aSLionel Sambuc // CHECK: @llvm.x86.sse.cmp.ss({{.*}}, i8 2)
56*f4a2713aSLionel Sambuc // CHECK: shufflevector <{{.*}}, <4 x i32> <i32 4, i32 1, i32 2, i32 3>
57*f4a2713aSLionel Sambuc return _mm_cmpge_ss(a, b);
58*f4a2713aSLionel Sambuc }
59*f4a2713aSLionel Sambuc
test_cmpngt_ss(__m128 a,__m128 b)60*f4a2713aSLionel Sambuc __m128 test_cmpngt_ss(__m128 a, __m128 b) {
61*f4a2713aSLionel Sambuc // CHECK: @llvm.x86.sse.cmp.ss({{.*}}, i8 5)
62*f4a2713aSLionel Sambuc // CHECK: shufflevector <{{.*}}, <4 x i32> <i32 4, i32 1, i32 2, i32 3>
63*f4a2713aSLionel Sambuc return _mm_cmpngt_ss(a, b);
64*f4a2713aSLionel Sambuc }
65*f4a2713aSLionel Sambuc
test_cmpnge_ss(__m128 a,__m128 b)66*f4a2713aSLionel Sambuc __m128 test_cmpnge_ss(__m128 a, __m128 b) {
67*f4a2713aSLionel Sambuc // CHECK: @llvm.x86.sse.cmp.ss({{.*}}, i8 6)
68*f4a2713aSLionel Sambuc // CHECK: shufflevector <{{.*}}, <4 x i32> <i32 4, i32 1, i32 2, i32 3>
69*f4a2713aSLionel Sambuc return _mm_cmpnge_ss(a, b);
70*f4a2713aSLionel Sambuc }
71*f4a2713aSLionel Sambuc
test_cmpgt_sd(__m128d a,__m128d b)72*f4a2713aSLionel Sambuc __m128d test_cmpgt_sd(__m128d a, __m128d b) {
73*f4a2713aSLionel Sambuc // CHECK: @llvm.x86.sse2.cmp.sd({{.*}}, i8 1)
74*f4a2713aSLionel Sambuc // CHECK: shufflevector <{{.*}}, <2 x i32> <i32 0, i32 3>
75*f4a2713aSLionel Sambuc return _mm_cmpgt_sd(a, b);
76*f4a2713aSLionel Sambuc }
77*f4a2713aSLionel Sambuc
test_cmpge_sd(__m128d a,__m128d b)78*f4a2713aSLionel Sambuc __m128d test_cmpge_sd(__m128d a, __m128d b) {
79*f4a2713aSLionel Sambuc // CHECK: @llvm.x86.sse2.cmp.sd({{.*}}, i8 2)
80*f4a2713aSLionel Sambuc // CHECK: shufflevector <{{.*}}, <2 x i32> <i32 0, i32 3>
81*f4a2713aSLionel Sambuc return _mm_cmpge_sd(a, b);
82*f4a2713aSLionel Sambuc }
83*f4a2713aSLionel Sambuc
test_cmpngt_sd(__m128d a,__m128d b)84*f4a2713aSLionel Sambuc __m128d test_cmpngt_sd(__m128d a, __m128d b) {
85*f4a2713aSLionel Sambuc // CHECK: @llvm.x86.sse2.cmp.sd({{.*}}, i8 5)
86*f4a2713aSLionel Sambuc // CHECK: shufflevector <{{.*}}, <2 x i32> <i32 0, i32 3>
87*f4a2713aSLionel Sambuc return _mm_cmpngt_sd(a, b);
88*f4a2713aSLionel Sambuc }
89*f4a2713aSLionel Sambuc
test_cmpnge_sd(__m128d a,__m128d b)90*f4a2713aSLionel Sambuc __m128d test_cmpnge_sd(__m128d a, __m128d b) {
91*f4a2713aSLionel Sambuc // CHECK: @llvm.x86.sse2.cmp.sd({{.*}}, i8 6)
92*f4a2713aSLionel Sambuc // CHECK: shufflevector <{{.*}}, <2 x i32> <i32 0, i32 3>
93*f4a2713aSLionel Sambuc return _mm_cmpnge_sd(a, b);
94*f4a2713aSLionel Sambuc }
95