1 // RUN: %clang_cc1 -flax-vector-conversions=none -ffreestanding %s -O3 -triple=x86_64-apple-darwin -target-feature +avx -emit-llvm -o - | FileCheck %s
2 // FIXME: The shufflevector instructions in test_cmpgt_sd are relying on O3 here.
3
4
5 #include <immintrin.h>
6
7 //
8 // Test LLVM IR codegen of cmpXY instructions
9 //
10
test_cmp_sd(__m128d a,__m128d b)11 __m128d test_cmp_sd(__m128d a, __m128d b) {
12 // Expects that the third argument in LLVM IR is immediate expression
13 // CHECK: @llvm.x86.sse2.cmp.sd({{.*}}, i8 13)
14 return _mm_cmp_sd(a, b, _CMP_GE_OS);
15 }
16
test_cmp_ss(__m128 a,__m128 b)17 __m128 test_cmp_ss(__m128 a, __m128 b) {
18 // Expects that the third argument in LLVM IR is immediate expression
19 // CHECK: @llvm.x86.sse.cmp.ss({{.*}}, i8 13)
20 return _mm_cmp_ss(a, b, _CMP_GE_OS);
21 }
22
test_cmpgt_ss(__m128 a,__m128 b)23 __m128 test_cmpgt_ss(__m128 a, __m128 b) {
24 // CHECK: @llvm.x86.sse.cmp.ss({{.*}}, i8 1)
25 // CHECK: shufflevector <{{.*}}, <4 x i32> <i32 0, i32 5, i32 6, i32 7>
26 return _mm_cmpgt_ss(a, b);
27 }
28
test_cmpge_ss(__m128 a,__m128 b)29 __m128 test_cmpge_ss(__m128 a, __m128 b) {
30 // CHECK: @llvm.x86.sse.cmp.ss({{.*}}, i8 2)
31 // CHECK: shufflevector <{{.*}}, <4 x i32> <i32 0, i32 5, i32 6, i32 7>
32 return _mm_cmpge_ss(a, b);
33 }
34
test_cmpngt_ss(__m128 a,__m128 b)35 __m128 test_cmpngt_ss(__m128 a, __m128 b) {
36 // CHECK: @llvm.x86.sse.cmp.ss({{.*}}, i8 5)
37 // CHECK: shufflevector <{{.*}}, <4 x i32> <i32 0, i32 5, i32 6, i32 7>
38 return _mm_cmpngt_ss(a, b);
39 }
40
test_cmpnge_ss(__m128 a,__m128 b)41 __m128 test_cmpnge_ss(__m128 a, __m128 b) {
42 // CHECK: @llvm.x86.sse.cmp.ss({{.*}}, i8 6)
43 // CHECK: shufflevector <{{.*}}, <4 x i32> <i32 0, i32 5, i32 6, i32 7>
44 return _mm_cmpnge_ss(a, b);
45 }
46
test_cmpgt_sd(__m128d a,__m128d b)47 __m128d test_cmpgt_sd(__m128d a, __m128d b) {
48 // CHECK: @llvm.x86.sse2.cmp.sd({{.*}}, i8 1)
49 // CHECK: shufflevector <{{.*}}, <2 x i32> <i32 0, i32 3>
50 return _mm_cmpgt_sd(a, b);
51 }
52
test_cmpge_sd(__m128d a,__m128d b)53 __m128d test_cmpge_sd(__m128d a, __m128d b) {
54 // CHECK: @llvm.x86.sse2.cmp.sd({{.*}}, i8 2)
55 // CHECK: shufflevector <{{.*}}, <2 x i32> <i32 0, i32 3>
56 return _mm_cmpge_sd(a, b);
57 }
58
test_cmpngt_sd(__m128d a,__m128d b)59 __m128d test_cmpngt_sd(__m128d a, __m128d b) {
60 // CHECK: @llvm.x86.sse2.cmp.sd({{.*}}, i8 5)
61 // CHECK: shufflevector <{{.*}}, <2 x i32> <i32 0, i32 3>
62 return _mm_cmpngt_sd(a, b);
63 }
64
test_cmpnge_sd(__m128d a,__m128d b)65 __m128d test_cmpnge_sd(__m128d a, __m128d b) {
66 // CHECK: @llvm.x86.sse2.cmp.sd({{.*}}, i8 6)
67 // CHECK: shufflevector <{{.*}}, <2 x i32> <i32 0, i32 3>
68 return _mm_cmpnge_sd(a, b);
69 }
70