Debian Codegraph @

clang/test/CodeGen/X86/sse42-builtins.c

raw
1 // RUN: %clang_cc1 -x c -flax-vector-conversions=none -ffreestanding %s -triple=x86_64-apple-darwin -target-feature +sse4.2 -emit-llvm -o - -Wall -Werror | FileCheck %s --check-prefixes=CHECK,X64
2 // RUN: %clang_cc1 -x c -flax-vector-conversions=none -ffreestanding %s -triple=x86_64-apple-darwin -target-feature +sse4.2 -fno-signed-char -emit-llvm -o - -Wall -Werror | FileCheck %s --check-prefixes=CHECK,X64
3 // RUN: %clang_cc1 -x c -flax-vector-conversions=none -ffreestanding %s -triple=i386-apple-darwin -target-feature +sse4.2 -emit-llvm -o - -Wall -Werror | FileCheck %s --check-prefixes=CHECK
4 // RUN: %clang_cc1 -x c -flax-vector-conversions=none -ffreestanding %s -triple=i386-apple-darwin -target-feature +sse4.2 -fno-signed-char -emit-llvm -o - -Wall -Werror | FileCheck %s --check-prefixes=CHECK
5 // RUN: %clang_cc1 -x c++ -flax-vector-conversions=none -ffreestanding %s -triple=x86_64-apple-darwin -target-feature +sse4.2 -emit-llvm -o - -Wall -Werror | FileCheck %s --check-prefixes=CHECK,X64
6 // RUN: %clang_cc1 -x c++ -flax-vector-conversions=none -ffreestanding %s -triple=x86_64-apple-darwin -target-feature +sse4.2 -fno-signed-char -emit-llvm -o - -Wall -Werror | FileCheck %s --check-prefixes=CHECK,X64
7 // RUN: %clang_cc1 -x c++ -flax-vector-conversions=none -ffreestanding %s -triple=i386-apple-darwin -target-feature +sse4.2 -emit-llvm -o - -Wall -Werror | FileCheck %s --check-prefixes=CHECK
8 // RUN: %clang_cc1 -x c++ -flax-vector-conversions=none -ffreestanding %s -triple=i386-apple-darwin -target-feature +sse4.2 -fno-signed-char -emit-llvm -o - -Wall -Werror | FileCheck %s --check-prefixes=CHECK
9
10 // RUN: %clang_cc1 -x c -flax-vector-conversions=none -ffreestanding %s -triple=x86_64-apple-darwin -target-feature +sse4.2 -emit-llvm -o - -Wall -Werror -fexperimental-new-constant-interpreter | FileCheck %s --check-prefixes=CHECK,X64
11 // RUN: %clang_cc1 -x c -flax-vector-conversions=none -ffreestanding %s -triple=x86_64-apple-darwin -target-feature +sse4.2 -fno-signed-char -emit-llvm -o - -Wall -Werror -fexperimental-new-constant-interpreter | FileCheck %s --check-prefixes=CHECK,X64
12 // RUN: %clang_cc1 -x c -flax-vector-conversions=none -ffreestanding %s -triple=i386-apple-darwin -target-feature +sse4.2 -emit-llvm -o - -Wall -Werror -fexperimental-new-constant-interpreter | FileCheck %s --check-prefixes=CHECK
13 // RUN: %clang_cc1 -x c -flax-vector-conversions=none -ffreestanding %s -triple=i386-apple-darwin -target-feature +sse4.2 -fno-signed-char -emit-llvm -o - -Wall -Werror -fexperimental-new-constant-interpreter | FileCheck %s --check-prefixes=CHECK
14 // RUN: %clang_cc1 -x c++ -flax-vector-conversions=none -ffreestanding %s -triple=x86_64-apple-darwin -target-feature +sse4.2 -emit-llvm -o - -Wall -Werror -fexperimental-new-constant-interpreter | FileCheck %s --check-prefixes=CHECK,X64
15 // RUN: %clang_cc1 -x c++ -flax-vector-conversions=none -ffreestanding %s -triple=x86_64-apple-darwin -target-feature +sse4.2 -fno-signed-char -emit-llvm -o - -Wall -Werror -fexperimental-new-constant-interpreter | FileCheck %s --check-prefixes=CHECK,X64
16 // RUN: %clang_cc1 -x c++ -flax-vector-conversions=none -ffreestanding %s -triple=i386-apple-darwin -target-feature +sse4.2 -emit-llvm -o - -Wall -Werror -fexperimental-new-constant-interpreter | FileCheck %s --check-prefixes=CHECK
17 // RUN: %clang_cc1 -x c++ -flax-vector-conversions=none -ffreestanding %s -triple=i386-apple-darwin -target-feature +sse4.2 -fno-signed-char -emit-llvm -o - -Wall -Werror -fexperimental-new-constant-interpreter | FileCheck %s --check-prefixes=CHECK
18
19
20 #include <immintrin.h>
21 #include "builtin_test_helpers.h"
22
23 // NOTE: This should match the tests in llvm/test/CodeGen/X86/sse42-intrinsics-fast-isel.ll
24
25 int test_mm_cmpestra(__m128i A, int LA, __m128i B, int LB) {
26 // CHECK-LABEL: test_mm_cmpestra
27 // CHECK: call {{.*}}i32 @llvm.x86.sse42.pcmpestria128(<16 x i8> %{{.*}}, i32 %{{.*}}, <16 x i8> %{{.*}}, i32 %{{.*}}, i8 7)
28 return _mm_cmpestra(A, LA, B, LB, 7);
29 }
30
31 int test_mm_cmpestrc(__m128i A, int LA, __m128i B, int LB) {
32 // CHECK-LABEL: test_mm_cmpestrc
33 // CHECK: call {{.*}}i32 @llvm.x86.sse42.pcmpestric128(<16 x i8> %{{.*}}, i32 %{{.*}}, <16 x i8> %{{.*}}, i32 %{{.*}}, i8 7)
34 return _mm_cmpestrc(A, LA, B, LB, 7);
35 }
36
37 int test_mm_cmpestri(__m128i A, int LA, __m128i B, int LB) {
38 // CHECK-LABEL: test_mm_cmpestri
39 // CHECK: call {{.*}}i32 @llvm.x86.sse42.pcmpestri128(<16 x i8> %{{.*}}, i32 %{{.*}}, <16 x i8> %{{.*}}, i32 %{{.*}}, i8 7)
40 return _mm_cmpestri(A, LA, B, LB, 7);
41 }
42
43 __m128i test_mm_cmpestrm(__m128i A, int LA, __m128i B, int LB) {
44 // CHECK-LABEL: test_mm_cmpestrm
45 // CHECK: call <16 x i8> @llvm.x86.sse42.pcmpestrm128(<16 x i8> %{{.*}}, i32 %{{.*}}, <16 x i8> %{{.*}}, i32 %{{.*}}, i8 7)
46 return _mm_cmpestrm(A, LA, B, LB, 7);
47 }
48
49 int test_mm_cmpestro(__m128i A, int LA, __m128i B, int LB) {
50 // CHECK-LABEL: test_mm_cmpestro
51 // CHECK: call {{.*}}i32 @llvm.x86.sse42.pcmpestrio128(<16 x i8> %{{.*}}, i32 %{{.*}}, <16 x i8> %{{.*}}, i32 %{{.*}}, i8 7)
52 return _mm_cmpestro(A, LA, B, LB, 7);
53 }
54
55 int test_mm_cmpestrs(__m128i A, int LA, __m128i B, int LB) {
56 // CHECK-LABEL: test_mm_cmpestrs
57 // CHECK: call {{.*}}i32 @llvm.x86.sse42.pcmpestris128(<16 x i8> %{{.*}}, i32 %{{.*}}, <16 x i8> %{{.*}}, i32 %{{.*}}, i8 7)
58 return _mm_cmpestrs(A, LA, B, LB, 7);
59 }
60
61 int test_mm_cmpestrz(__m128i A, int LA, __m128i B, int LB) {
62 // CHECK-LABEL: test_mm_cmpestrz
63 // CHECK: call {{.*}}i32 @llvm.x86.sse42.pcmpestriz128(<16 x i8> %{{.*}}, i32 %{{.*}}, <16 x i8> %{{.*}}, i32 %{{.*}}, i8 7)
64 return _mm_cmpestrz(A, LA, B, LB, 7);
65 }
66
67 __m128i test_mm_cmpgt_epi64(__m128i A, __m128i B) {
68 // CHECK-LABEL: test_mm_cmpgt_epi64
69 // CHECK: icmp sgt <2 x i64>
70 return _mm_cmpgt_epi64(A, B);
71 }
72 TEST_CONSTEXPR(match_v2di(_mm_cmpgt_epi64((__m128i)(__v2di){+1, -8}, (__m128i)(__v2di){-10, -8}), -1, 0));
73
74 int test_mm_cmpistra(__m128i A, __m128i B) {
75 // CHECK-LABEL: test_mm_cmpistra
76 // CHECK: call {{.*}}i32 @llvm.x86.sse42.pcmpistria128(<16 x i8> %{{.*}}, <16 x i8> %{{.*}}, i8 7)
77 return _mm_cmpistra(A, B, 7);
78 }
79
80 int test_mm_cmpistrc(__m128i A, __m128i B) {
81 // CHECK-LABEL: test_mm_cmpistrc
82 // CHECK: call {{.*}}i32 @llvm.x86.sse42.pcmpistric128(<16 x i8> %{{.*}}, <16 x i8> %{{.*}}, i8 7)
83 return _mm_cmpistrc(A, B, 7);
84 }
85
86 int test_mm_cmpistri(__m128i A, __m128i B) {
87 // CHECK-LABEL: test_mm_cmpistri
88 // CHECK: call {{.*}}i32 @llvm.x86.sse42.pcmpistri128(<16 x i8> %{{.*}}, <16 x i8> %{{.*}}, i8 7)
89 return _mm_cmpistri(A, B, 7);
90 }
91
92 __m128i test_mm_cmpistrm(__m128i A, __m128i B) {
93 // CHECK-LABEL: test_mm_cmpistrm
94 // CHECK: call <16 x i8> @llvm.x86.sse42.pcmpistrm128(<16 x i8> %{{.*}}, <16 x i8> %{{.*}}, i8 7)
95 return _mm_cmpistrm(A, B, 7);
96 }
97
98 int test_mm_cmpistro(__m128i A, __m128i B) {
99 // CHECK-LABEL: test_mm_cmpistro
100 // CHECK: call {{.*}}i32 @llvm.x86.sse42.pcmpistrio128(<16 x i8> %{{.*}}, <16 x i8> %{{.*}}, i8 7)
101 return _mm_cmpistro(A, B, 7);
102 }
103
104 int test_mm_cmpistrs(__m128i A, __m128i B) {
105 // CHECK-LABEL: test_mm_cmpistrs
106 // CHECK: call {{.*}}i32 @llvm.x86.sse42.pcmpistris128(<16 x i8> %{{.*}}, <16 x i8> %{{.*}}, i8 7)
107 return _mm_cmpistrs(A, B, 7);
108 }
109
110 int test_mm_cmpistrz(__m128i A, __m128i B) {
111 // CHECK-LABEL: test_mm_cmpistrz
112 // CHECK: call {{.*}}i32 @llvm.x86.sse42.pcmpistriz128(<16 x i8> %{{.*}}, <16 x i8> %{{.*}}, i8 7)
113 return _mm_cmpistrz(A, B, 7);
114 }
115
116 unsigned int test_mm_crc32_u8(unsigned int CRC, unsigned char V) {
117 // CHECK-LABEL: test_mm_crc32_u8
118 // CHECK: call {{.*}}i32 @llvm.x86.sse42.crc32.32.8(i32 %{{.*}}, i8 %{{.*}})
119 return _mm_crc32_u8(CRC, V);
120 }
121
122 unsigned int test_mm_crc32_u16(unsigned int CRC, unsigned short V) {
123 // CHECK-LABEL: test_mm_crc32_u16
124 // CHECK: call {{.*}}i32 @llvm.x86.sse42.crc32.32.16(i32 %{{.*}}, i16 %{{.*}})
125 return _mm_crc32_u16(CRC, V);
126 }
127
128 unsigned int test_mm_crc32_u32(unsigned int CRC, unsigned int V) {
129 // CHECK-LABEL: test_mm_crc32_u32
130 // CHECK: call {{.*}}i32 @llvm.x86.sse42.crc32.32.32(i32 %{{.*}}, i32 %{{.*}})
131 return _mm_crc32_u32(CRC, V);
132 }
133
134 #ifdef __x86_64__
135 unsigned long long test_mm_crc32_u64(unsigned long long CRC, unsigned long long V) {
136 // X64-LABEL: test_mm_crc32_u64
137 // X64: call {{.*}}i64 @llvm.x86.sse42.crc32.64.64(i64 %{{.*}}, i64 %{{.*}})
138 return _mm_crc32_u64(CRC, V);
139 }
140 #endif