Debian Codegraph @

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

raw
1 // RUN: %clang_cc1 -x c -flax-vector-conversions=none -ffreestanding %s -triple=x86_64-apple-darwin -target-feature +avx512bitalg -target-feature +avx512vl -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 +avx512bitalg -target-feature +avx512vl -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 +avx512bitalg -target-feature +avx512vl -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 +avx512bitalg -target-feature +avx512vl -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 +avx512bitalg -target-feature +avx512vl -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 +avx512bitalg -target-feature +avx512vl -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 +avx512bitalg -target-feature +avx512vl -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 +avx512bitalg -target-feature +avx512vl -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 __m256i test_mm256_popcnt_epi16(__m256i __A) {
16 // CHECK-LABEL: test_mm256_popcnt_epi16
17 // CHECK: @llvm.ctpop.v16i16
18 return _mm256_popcnt_epi16(__A);
19 }
20 TEST_CONSTEXPR(match_v16hi(_mm256_popcnt_epi16((__m256i)(__v16hi){+5, -3, -10, +8, 0, -256, +256, -128, +3, +9, +15, +33, +63, +129, +511, +1025}), 2, 15, 14, 1, 0, 8, 1, 9, 2, 2, 4, 2, 6, 2, 9, 2));
21
22 __m256i test_mm256_mask_popcnt_epi16(__m256i __A, __mmask16 __U, __m256i __B) {
23 // CHECK-LABEL: test_mm256_mask_popcnt_epi16
24 // CHECK: @llvm.ctpop.v16i16
25 // CHECK: select <16 x i1> %{{[0-9]+}}, <16 x i16> %{{.*}}, <16 x i16> %{{.*}}
26 return _mm256_mask_popcnt_epi16(__A, __U, __B);
27 }
28 TEST_CONSTEXPR(match_v16hi(_mm256_mask_popcnt_epi16(_mm256_set1_epi16(-1), 0xF0F0, (__m256i)(__v16hi){+5, -3, -10, +8, 0, -256, +256, -128, +3, +9, +15, +33, +63, +129, +511, +1025}), -1, -1, -1, -1, 0, 8, 1, 9, -1, -1, -1, -1, 6, 2, 9, 2));
29
30 __m256i test_mm256_maskz_popcnt_epi16(__mmask16 __U, __m256i __B) {
31 // CHECK-LABEL: test_mm256_maskz_popcnt_epi16
32 // CHECK: @llvm.ctpop.v16i16
33 // CHECK: select <16 x i1> %{{[0-9]+}}, <16 x i16> %{{.*}}, <16 x i16> %{{.*}}
34 return _mm256_maskz_popcnt_epi16(__U, __B);
35 }
36 TEST_CONSTEXPR(match_v16hi(_mm256_maskz_popcnt_epi16(0x0F0F, (__m256i)(__v16hi){+5, -3, -10, +8, 0, -256, +256, -128, +3, +9, +15, +33, +63, +129, +511, +1025}), 2, 15, 14, 1, 0, 0, 0, 0, 2, 2, 4, 2, 0, 0, 0, 0));
37
38 __m128i test_mm_popcnt_epi16(__m128i __A) {
39 // CHECK-LABEL: test_mm_popcnt_epi16
40 // CHECK: @llvm.ctpop.v8i16
41 return _mm_popcnt_epi16(__A);
42 }
43 TEST_CONSTEXPR(match_v8hi(_mm_popcnt_epi16((__m128i)(__v8hi){+5, -3, -10, +8, 0, -256, +256, -128}), 2, 15, 14, 1, 0, 8, 1, 9));
44
45 __m128i test_mm_mask_popcnt_epi16(__m128i __A, __mmask8 __U, __m128i __B) {
46 // CHECK-LABEL: test_mm_mask_popcnt_epi16
47 // CHECK: @llvm.ctpop.v8i16
48 // CHECK: select <8 x i1> %{{[0-9]+}}, <8 x i16> %{{.*}}, <8 x i16> %{{.*}}
49 return _mm_mask_popcnt_epi16(__A, __U, __B);
50 }
51 TEST_CONSTEXPR(match_v8hi(_mm_mask_popcnt_epi16(_mm_set1_epi16(-1), 0xF0, (__m128i)(__v8hi){+5, -3, -10, +8, 0, -256, +256, -128}), -1, -1, -1, -1, 0, 8, 1, 9));
52
53 __m128i test_mm_maskz_popcnt_epi16(__mmask8 __U, __m128i __B) {
54 // CHECK-LABEL: test_mm_maskz_popcnt_epi16
55 // CHECK: @llvm.ctpop.v8i16
56 // CHECK: select <8 x i1> %{{[0-9]+}}, <8 x i16> %{{.*}}, <8 x i16> %{{.*}}
57 return _mm_maskz_popcnt_epi16(__U, __B);
58 }
59 TEST_CONSTEXPR(match_v8hi(_mm_maskz_popcnt_epi16(0x0F, (__m128i)(__v8hi){+5, -3, -10, +8, 0, -256, +256, -128}), 2, 15, 14, 1, 0, 0, 0, 0));
60
61 __m256i test_mm256_popcnt_epi8(__m256i __A) {
62 // CHECK-LABEL: test_mm256_popcnt_epi8
63 // CHECK: @llvm.ctpop.v32i8
64 return _mm256_popcnt_epi8(__A);
65 }
66 TEST_CONSTEXPR(match_v32qi(_mm256_popcnt_epi8((__m256i)(__v32qi){+5, -3, -10, +8, 0, -16, +16, -16, +3, +9, +15, +33, +63, +33, +53, +73, +5, -3, -10, +8, 0, -16, +16, -16, +3, +9, +15, +33, +63, +33, +53, +73}), 2, 7, 6, 1, 0, 4, 1, 4, 2, 2, 4, 2, 6, 2, 4, 3, 2, 7, 6, 1, 0, 4, 1, 4, 2, 2, 4, 2, 6, 2, 4, 3));
67
68 __m256i test_mm256_mask_popcnt_epi8(__m256i __A, __mmask32 __U, __m256i __B) {
69 // CHECK-LABEL: test_mm256_mask_popcnt_epi8
70 // CHECK: @llvm.ctpop.v32i8
71 // CHECK: select <32 x i1> %{{[0-9]+}}, <32 x i8> %{{.*}}, <32 x i8> %{{.*}}
72 return _mm256_mask_popcnt_epi8(__A, __U, __B);
73 }
74 TEST_CONSTEXPR(match_v32qi(_mm256_mask_popcnt_epi8(_mm256_set1_epi8(-1), 0xF00F, (__m256i)(__v32qi){+5, -3, -10, +8, 0, -16, +16, -16, +3, +9, +15, +33, +63, +33, +53, +73, +5, -3, -10, +8, 0, -16, +16, -16, +3, +9, +15, +33, +63, +33, +53, +73}), 2, 7, 6, 1, -1, -1, -1, -1, -1, -1, -1, -1, 6, 2, 4, 3, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1));
75
76 __m256i test_mm256_maskz_popcnt_epi8(__mmask32 __U, __m256i __B) {
77 // CHECK-LABEL: test_mm256_maskz_popcnt_epi8
78 // CHECK: @llvm.ctpop.v32i8
79 // CHECK: select <32 x i1> %{{[0-9]+}}, <32 x i8> %{{.*}}, <32 x i8> %{{.*}}
80 return _mm256_maskz_popcnt_epi8(__U, __B);
81 }
82 TEST_CONSTEXPR(match_v32qi(_mm256_maskz_popcnt_epi8(0x0FF0, (__m256i)(__v32qi){+5, -3, -10, +8, 0, -16, +16, -16, +3, +9, +15, +33, +63, +33, +53, +73, +5, -3, -10, +8, 0, -16, +16, -16, +3, +9, +15, +33, +63, +33, +53, +73}), 0, 0, 0, 0, 0, 4, 1, 4, 2, 2, 4, 2, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0));
83
84 __m128i test_mm_popcnt_epi8(__m128i __A) {
85 // CHECK-LABEL: test_mm_popcnt_epi8
86 // CHECK: @llvm.ctpop.v16i8
87 return _mm_popcnt_epi8(__A);
88 }
89 TEST_CONSTEXPR(match_v16qi(_mm_popcnt_epi8((__m128i)(__v16qi){+5, -3, -10, +8, 0, -16, +16, -16, +3, +9, +15, +33, +63, +33, +53, +73}), 2, 7, 6, 1, 0, 4, 1, 4, 2, 2, 4, 2, 6, 2, 4, 3));
90
91 __m128i test_mm_mask_popcnt_epi8(__m128i __A, __mmask16 __U, __m128i __B) {
92 // CHECK-LABEL: test_mm_mask_popcnt_epi8
93 // CHECK: @llvm.ctpop.v16i8
94 // CHECK: select <16 x i1> %{{[0-9]+}}, <16 x i8> %{{.*}}, <16 x i8> %{{.*}}
95 return _mm_mask_popcnt_epi8(__A, __U, __B);
96 }
97 TEST_CONSTEXPR(match_v16qi(_mm_mask_popcnt_epi8(_mm_set1_epi8(-1), 0xF00F, (__m128i)(__v16qi){+5, -3, -10, +8, 0, -16, +16, -16, +3, +9, +15, +33, +63, +33, +53, +73}), 2, 7, 6, 1, -1, -1, -1, -1, -1, -1, -1, -1, 6, 2, 4, 3));
98
99 __m128i test_mm_maskz_popcnt_epi8(__mmask16 __U, __m128i __B) {
100 // CHECK-LABEL: test_mm_maskz_popcnt_epi8
101 // CHECK: @llvm.ctpop.v16i8
102 // CHECK: select <16 x i1> %{{[0-9]+}}, <16 x i8> %{{.*}}, <16 x i8> %{{.*}}
103 return _mm_maskz_popcnt_epi8(__U, __B);
104 }
105 TEST_CONSTEXPR(match_v16qi(_mm_maskz_popcnt_epi8(0x0FF0, (__m128i)(__v16qi){+5, -3, -10, +8, 0, -16, +16, -16, +3, +9, +15, +33, +63, +33, +53, +73}), 0, 0, 0, 0, 0, 4, 1, 4, 2, 2, 4, 2, 0, 0, 0, 0));
106
107 __mmask32 test_mm256_mask_bitshuffle_epi64_mask(__mmask32 __U, __m256i __A, __m256i __B) {
108 // CHECK-LABEL: test_mm256_mask_bitshuffle_epi64_mask
109 // CHECK: @llvm.x86.avx512.vpshufbitqmb.256
110 // CHECK: and <32 x i1> %{{.*}}, %{{.*}}
111 return _mm256_mask_bitshuffle_epi64_mask(__U, __A, __B);
112 }
113
114 __mmask32 test_mm256_bitshuffle_epi64_mask(__m256i __A, __m256i __B) {
115 // CHECK-LABEL: test_mm256_bitshuffle_epi64_mask
116 // CHECK: @llvm.x86.avx512.vpshufbitqmb.256
117 return _mm256_bitshuffle_epi64_mask(__A, __B);
118 }
119 TEST_CONSTEXPR(_mm256_bitshuffle_epi64_mask(
120 (__m256i)(__v32qi){1,0,0,0,0,0,0,0, 0,0,0,0,0,0,0,-128, -1,0,0,0,0,0,0,0, 85,85,85,85,85,85,85,85},
121 (__m256i)(__v32qi){0,1,2,3,4,5,6,7, 63,62,61,60,59,58,57,56, 0,1,2,3,4,5,6,7, 0,1,2,3,4,5,6,7}) == 0x55ff0101);
122
123 TEST_CONSTEXPR(_mm256_mask_bitshuffle_epi64_mask(0xFFFF0000,
124 (__m256i)(__v32qi){1,0,0,0,0,0,0,0, 0,0,0,0,0,0,0,-128, -1,0,0,0,0,0,0,0, 85,85,85,85,85,85,85,85},
125 (__m256i)(__v32qi){0,1,2,3,4,5,6,7, 63,62,61,60,59,58,57,56, 0,1,2,3,4,5,6,7, 0,1,2,3,4,5,6,7}) == 0x55ff0000);
126
127 __mmask16 test_mm_mask_bitshuffle_epi64_mask(__mmask16 __U, __m128i __A, __m128i __B) {
128 // CHECK-LABEL: test_mm_mask_bitshuffle_epi64_mask
129 // CHECK: @llvm.x86.avx512.vpshufbitqmb.128
130 // CHECK: and <16 x i1> %{{.*}}, %{{.*}}
131 return _mm_mask_bitshuffle_epi64_mask(__U, __A, __B);
132 }
133
134 __mmask16 test_mm_bitshuffle_epi64_mask(__m128i __A, __m128i __B) {
135 // CHECK-LABEL: test_mm_bitshuffle_epi64_mask
136 // CHECK: @llvm.x86.avx512.vpshufbitqmb.128
137 return _mm_bitshuffle_epi64_mask(__A, __B);
138 }
139 TEST_CONSTEXPR(_mm_bitshuffle_epi64_mask(
140 (__m128i)(__v16qi){1,0,0,0,0,0,0,0, 0,0,0,0,0,0,0,-128},
141 (__m128i)(__v16qi){0,1,2,3,4,5,6,7, 63,62,61,60,59,58,57,56}) == 0x0101);
142
143 TEST_CONSTEXPR(_mm_mask_bitshuffle_epi64_mask(0xFF00,
144 (__m128i)(__v16qi){1,0,0,0,0,0,0,0, 0,0,0,0,0,0,0,-128},
145 (__m128i)(__v16qi){0,1,2,3,4,5,6,7, 63,62,61,60,59,58,57,56}) == 0x0100);
146