Debian Codegraph @

clang/test/CIR/CodeGenBuiltins/X86/avx512bw-builtins.c

raw
1 // RUN: %clang_cc1 -x c -flax-vector-conversions=none -ffreestanding %s -triple=x86_64-unknown-linux -target-feature +avx512bw -fclangir -emit-cir -o %t.cir -Wall -Werror -Wsign-conversion
2 // RUN: FileCheck --check-prefix=CIR --input-file=%t.cir %s
3
4 // RUN: %clang_cc1 -x c++ -flax-vector-conversions=none -ffreestanding %s -triple=x86_64-unknown-linux -target-feature +avx512bw -fclangir -emit-cir -o %t.cir -Wall -Werror -Wsign-conversion
5 // RUN: FileCheck --check-prefix=CIR --input-file=%t.cir %s
6
7 // RUN: %clang_cc1 -x c -flax-vector-conversions=none -ffreestanding %s -triple=x86_64-unknown-linux -target-feature +avx512bw -fclangir -emit-llvm -o %t.ll -Wall -Werror -Wsign-conversion
8 // RUN: FileCheck --check-prefixes=LLVM --input-file=%t.ll %s
9
10 // RUN: %clang_cc1 -x c++ -flax-vector-conversions=none -ffreestanding %s -triple=x86_64-unknown-linux -target-feature +avx512bw -fclangir -emit-llvm -o %t.ll -Wall -Werror -Wsign-conversion
11 // RUN: FileCheck --check-prefixes=LLVM --input-file=%t.ll %s
12
13 // RUN: %clang_cc1 -x c -flax-vector-conversions=none -ffreestanding %s -triple=x86_64-unknown-linux -target-feature +avx512bw -emit-llvm -o - -Wall -Werror -Wsign-conversion | FileCheck %s --check-prefix=OGCG
14 // RUN: %clang_cc1 -x c -flax-vector-conversions=none -ffreestanding %s -triple=x86_64-apple-darwin -target-feature +avx512bw -emit-llvm -o - -Wall -Werror -Wsign-conversion | FileCheck %s --check-prefixes=OGCG
15
16 // RUN: %clang_cc1 -x c++ -flax-vector-conversions=none -ffreestanding %s -triple=x86_64-unknown-linux -target-feature +avx512bw -emit-llvm -o - -Wall -Werror -Wsign-conversion | FileCheck %s --check-prefix=OGCG
17 // RUN: %clang_cc1 -x c++ -flax-vector-conversions=none -ffreestanding %s -triple=x86_64-apple-darwin -target-feature +avx512bw -emit-llvm -o - -Wall -Werror -Wsign-conversion | FileCheck %s --check-prefixes=OGCG
18
19 // This test mimics clang/test/CodeGen/X86/avx512bw-builtins.c, which eventually
20 // CIR shall be able to support fully.
21
22 #include <immintrin.h>
23
24 __mmask32 test_kshiftli_mask32(__mmask32 A) {
25 // CIR-LABEL: test_kshiftli_mask32
26 // CIR: [[VAL:%.*]] = cir.cast bitcast %{{.*}} : !u32i -> !cir.vector<32 x !cir.int<s, 1>>
27 // CIR: [[SHIFT:%.*]] = cir.const #cir.zero : !cir.vector<32 x !cir.int<s, 1>>
28 // CIR: %{{.*}} = cir.vec.shuffle([[SHIFT]], [[VAL]] : !cir.vector<32 x !cir.int<s, 1>>) [#cir.int<1> : !s32i, #cir.int<2> : !s32i, #cir.int<3> : !s32i, #cir.int<4> : !s32i, #cir.int<5> : !s32i, #cir.int<6> : !s32i, #cir.int<7> : !s32i, #cir.int<8> : !s32i, #cir.int<9> : !s32i, #cir.int<10> : !s32i, #cir.int<11> : !s32i, #cir.int<12> : !s32i, #cir.int<13> : !s32i, #cir.int<14> : !s32i, #cir.int<15> : !s32i, #cir.int<16> : !s32i, #cir.int<17> : !s32i, #cir.int<18> : !s32i, #cir.int<19> : !s32i, #cir.int<20> : !s32i, #cir.int<21> : !s32i, #cir.int<22> : !s32i, #cir.int<23> : !s32i, #cir.int<24> : !s32i, #cir.int<25> : !s32i, #cir.int<26> : !s32i, #cir.int<27> : !s32i, #cir.int<28> : !s32i, #cir.int<29> : !s32i, #cir.int<30> : !s32i, #cir.int<31> : !s32i, #cir.int<32> : !s32i] : !cir.vector<32 x !cir.int<s, 1>>
29
30 // LLVM-LABEL: test_kshiftli_mask32
31 // LLVM: [[VAL:%.*]] = bitcast i32 %{{.*}} to <32 x i1>
32 // LLVM: [[RES:%.*]] = shufflevector <32 x i1> zeroinitializer, <32 x i1> [[VAL]], <32 x i32> <i32 1, i32 2, i32 3, i32 4, i32 5, i32 6, i32 7, i32 8, i32 9, i32 10, i32 11, i32 12, i32 13, i32 14, i32 15, i32 16, i32 17, i32 18, i32 19, i32 20, i32 21, i32 22, i32 23, i32 24, i32 25, i32 26, i32 27, i32 28, i32 29, i32 30, i32 31, i32 32>
33
34 // OGCG-LABEL: test_kshiftli_mask32
35 // OGCG: [[VAL:%.*]] = bitcast i32 %{{.*}} to <32 x i1>
36 // OGCG: [[RES:%.*]] = shufflevector <32 x i1> zeroinitializer, <32 x i1> [[VAL]], <32 x i32> <i32 1, i32 2, i32 3, i32 4, i32 5, i32 6, i32 7, i32 8, i32 9, i32 10, i32 11, i32 12, i32 13, i32 14, i32 15, i32 16, i32 17, i32 18, i32 19, i32 20, i32 21, i32 22, i32 23, i32 24, i32 25, i32 26, i32 27, i32 28, i32 29, i32 30, i32 31, i32 32>
37 return _kshiftli_mask32(A, 31);
38 }
39
40 __mmask32 test_kshiftri_mask32(__mmask32 A) {
41 // CIR-LABEL: test_kshiftri_mask32
42 // CIR: [[VAL:%.*]] = cir.cast bitcast %{{.*}} : !u32i -> !cir.vector<32 x !cir.int<s, 1>>
43 // CIR: [[SHIFT:%.*]] = cir.const #cir.zero : !cir.vector<32 x !cir.int<s, 1>>
44 // CIR: %{{.*}} = cir.vec.shuffle([[VAL]], [[SHIFT]] : !cir.vector<32 x !cir.int<s, 1>>) [#cir.int<31> : !s32i, #cir.int<32> : !s32i, #cir.int<33> : !s32i, #cir.int<34> : !s32i, #cir.int<35> : !s32i, #cir.int<36> : !s32i, #cir.int<37> : !s32i, #cir.int<38> : !s32i, #cir.int<39> : !s32i, #cir.int<40> : !s32i, #cir.int<41> : !s32i, #cir.int<42> : !s32i, #cir.int<43> : !s32i, #cir.int<44> : !s32i, #cir.int<45> : !s32i, #cir.int<46> : !s32i, #cir.int<47> : !s32i, #cir.int<48> : !s32i, #cir.int<49> : !s32i, #cir.int<50> : !s32i, #cir.int<51> : !s32i, #cir.int<52> : !s32i, #cir.int<53> : !s32i, #cir.int<54> : !s32i, #cir.int<55> : !s32i, #cir.int<56> : !s32i, #cir.int<57> : !s32i, #cir.int<58> : !s32i, #cir.int<59> : !s32i, #cir.int<60> : !s32i, #cir.int<61> : !s32i, #cir.int<62> : !s32i] : !cir.vector<32 x !cir.int<s, 1>>
45
46 // LLVM-LABEL: test_kshiftri_mask32
47 // LLVM: [[VAL:%.*]] = bitcast i32 %{{.*}} to <32 x i1>
48 // LLVM: [[RES:%.*]] = shufflevector <32 x i1> [[VAL]], <32 x i1> zeroinitializer, <32 x i32> <i32 31, i32 32, i32 33, i32 34, i32 35, i32 36, i32 37, i32 38, i32 39, i32 40, i32 41, i32 42, i32 43, i32 44, i32 45, i32 46, i32 47, i32 48, i32 49, i32 50, i32 51, i32 52, i32 53, i32 54, i32 55, i32 56, i32 57, i32 58, i32 59, i32 60, i32 61, i32 62>
49
50 // OGCG-LABEL: test_kshiftri_mask32
51 // OGCG: [[VAL:%.*]] = bitcast i32 %{{.*}} to <32 x i1>
52 // OGCG: [[RES:%.*]] = shufflevector <32 x i1> [[VAL]], <32 x i1> zeroinitializer, <32 x i32> <i32 31, i32 32, i32 33, i32 34, i32 35, i32 36, i32 37, i32 38, i32 39, i32 40, i32 41, i32 42, i32 43, i32 44, i32 45, i32 46, i32 47, i32 48, i32 49, i32 50, i32 51, i32 52, i32 53, i32 54, i32 55, i32 56, i32 57, i32 58, i32 59, i32 60, i32 61, i32 62>
53 return _kshiftri_mask32(A, 31);
54 }
55
56 __mmask64 test_kshiftli_mask64(__mmask64 A) {
57 // CIR-LABEL: test_kshiftli_mask64
58 // CIR: [[VAL:%.*]] = cir.cast bitcast %{{.*}} : !u64i -> !cir.vector<64 x !cir.int<s, 1>>
59 // CIR: [[SHIFT:%.*]] = cir.const #cir.zero : !cir.vector<64 x !cir.int<s, 1>>
60 // CIR: %{{.*}} = cir.vec.shuffle([[SHIFT]], [[VAL]] : !cir.vector<64 x !cir.int<s, 1>>) [#cir.int<32> : !s32i, #cir.int<33> : !s32i, #cir.int<34> : !s32i, #cir.int<35> : !s32i, #cir.int<36> : !s32i, #cir.int<37> : !s32i, #cir.int<38> : !s32i, #cir.int<39> : !s32i, #cir.int<40> : !s32i, #cir.int<41> : !s32i, #cir.int<42> : !s32i, #cir.int<43> : !s32i, #cir.int<44> : !s32i, #cir.int<45> : !s32i, #cir.int<46> : !s32i, #cir.int<47> : !s32i, #cir.int<48> : !s32i, #cir.int<49> : !s32i, #cir.int<50> : !s32i, #cir.int<51> : !s32i, #cir.int<52> : !s32i, #cir.int<53> : !s32i, #cir.int<54> : !s32i, #cir.int<55> : !s32i, #cir.int<56> : !s32i, #cir.int<57> : !s32i, #cir.int<58> : !s32i, #cir.int<59> : !s32i, #cir.int<60> : !s32i, #cir.int<61> : !s32i, #cir.int<62> : !s32i, #cir.int<63> : !s32i, #cir.int<64> : !s32i, #cir.int<65> : !s32i, #cir.int<66> : !s32i, #cir.int<67> : !s32i, #cir.int<68> : !s32i, #cir.int<69> : !s32i, #cir.int<70> : !s32i, #cir.int<71> : !s32i, #cir.int<72> : !s32i, #cir.int<73> : !s32i, #cir.int<74> : !s32i, #cir.int<75> : !s32i, #cir.int<76> : !s32i, #cir.int<77> : !s32i, #cir.int<78> : !s32i, #cir.int<79> : !s32i, #cir.int<80> : !s32i, #cir.int<81> : !s32i, #cir.int<82> : !s32i, #cir.int<83> : !s32i, #cir.int<84> : !s32i, #cir.int<85> : !s32i, #cir.int<86> : !s32i, #cir.int<87> : !s32i, #cir.int<88> : !s32i, #cir.int<89> : !s32i, #cir.int<90> : !s32i, #cir.int<91> : !s32i, #cir.int<92> : !s32i, #cir.int<93> : !s32i, #cir.int<94> : !s32i, #cir.int<95> : !s32i] : !cir.vector<64 x !cir.int<s, 1>>
61
62 // LLVM-LABEL: test_kshiftli_mask64
63 // LLVM: [[VAL:%.*]] = bitcast i64 %{{.*}} to <64 x i1>
64 // LLVM: [[RES:%.*]] = shufflevector <64 x i1> zeroinitializer, <64 x i1> [[VAL]], <64 x i32> <i32 32, i32 33, i32 34, i32 35, i32 36, i32 37, i32 38, i32 39, i32 40, i32 41, i32 42, i32 43, i32 44, i32 45, i32 46, i32 47, i32 48, i32 49, i32 50, i32 51, i32 52, i32 53, i32 54, i32 55, i32 56, i32 57, i32 58, i32 59, i32 60, i32 61, i32 62, i32 63, i32 64, i32 65, i32 66, i32 67, i32 68, i32 69, i32 70, i32 71, i32 72, i32 73, i32 74, i32 75, i32 76, i32 77, i32 78, i32 79, i32 80, i32 81, i32 82, i32 83, i32 84, i32 85, i32 86, i32 87, i32 88, i32 89, i32 90, i32 91, i32 92, i32 93, i32 94, i32 95>
65
66 // OGCG-LABEL: test_kshiftli_mask64
67 // OGCG: [[VAL:%.*]] = bitcast i64 %{{.*}} to <64 x i1>
68 // OGCG: [[RES:%.*]] = shufflevector <64 x i1> zeroinitializer, <64 x i1> [[VAL]], <64 x i32> <i32 32, i32 33, i32 34, i32 35, i32 36, i32 37, i32 38, i32 39, i32 40, i32 41, i32 42, i32 43, i32 44, i32 45, i32 46, i32 47, i32 48, i32 49, i32 50, i32 51, i32 52, i32 53, i32 54, i32 55, i32 56, i32 57, i32 58, i32 59, i32 60, i32 61, i32 62, i32 63, i32 64, i32 65, i32 66, i32 67, i32 68, i32 69, i32 70, i32 71, i32 72, i32 73, i32 74, i32 75, i32 76, i32 77, i32 78, i32 79, i32 80, i32 81, i32 82, i32 83, i32 84, i32 85, i32 86, i32 87, i32 88, i32 89, i32 90, i32 91, i32 92, i32 93, i32 94, i32 95>
69 return _kshiftli_mask64(A, 32);
70 }
71
72 __mmask64 test_kshiftri_mask64(__mmask64 A) {
73 // CIR-LABEL: test_kshiftri_mask64
74 // CIR: [[VAL:%.*]] = cir.cast bitcast %{{.*}} : !u64i -> !cir.vector<64 x !cir.int<s, 1>>
75 // CIR: [[SHIFT:%.*]] = cir.const #cir.zero : !cir.vector<64 x !cir.int<s, 1>>
76 // CIR: %{{.*}} = cir.vec.shuffle([[VAL]], [[SHIFT]] : !cir.vector<64 x !cir.int<s, 1>>) [#cir.int<32> : !s32i, #cir.int<33> : !s32i, #cir.int<34> : !s32i, #cir.int<35> : !s32i, #cir.int<36> : !s32i, #cir.int<37> : !s32i, #cir.int<38> : !s32i, #cir.int<39> : !s32i, #cir.int<40> : !s32i, #cir.int<41> : !s32i, #cir.int<42> : !s32i, #cir.int<43> : !s32i, #cir.int<44> : !s32i, #cir.int<45> : !s32i, #cir.int<46> : !s32i, #cir.int<47> : !s32i, #cir.int<48> : !s32i, #cir.int<49> : !s32i, #cir.int<50> : !s32i, #cir.int<51> : !s32i, #cir.int<52> : !s32i, #cir.int<53> : !s32i, #cir.int<54> : !s32i, #cir.int<55> : !s32i, #cir.int<56> : !s32i, #cir.int<57> : !s32i, #cir.int<58> : !s32i, #cir.int<59> : !s32i, #cir.int<60> : !s32i, #cir.int<61> : !s32i, #cir.int<62> : !s32i, #cir.int<63> : !s32i, #cir.int<64> : !s32i, #cir.int<65> : !s32i, #cir.int<66> : !s32i, #cir.int<67> : !s32i, #cir.int<68> : !s32i, #cir.int<69> : !s32i, #cir.int<70> : !s32i, #cir.int<71> : !s32i, #cir.int<72> : !s32i, #cir.int<73> : !s32i, #cir.int<74> : !s32i, #cir.int<75> : !s32i, #cir.int<76> : !s32i, #cir.int<77> : !s32i, #cir.int<78> : !s32i, #cir.int<79> : !s32i, #cir.int<80> : !s32i, #cir.int<81> : !s32i, #cir.int<82> : !s32i, #cir.int<83> : !s32i, #cir.int<84> : !s32i, #cir.int<85> : !s32i, #cir.int<86> : !s32i, #cir.int<87> : !s32i, #cir.int<88> : !s32i, #cir.int<89> : !s32i, #cir.int<90> : !s32i, #cir.int<91> : !s32i, #cir.int<92> : !s32i, #cir.int<93> : !s32i, #cir.int<94> : !s32i, #cir.int<95> : !s32i] : !cir.vector<64 x !cir.int<s, 1>>
77
78 // LLVM-LABEL: test_kshiftri_mask64
79 // LLVM: [[VAL:%.*]] = bitcast i64 %{{.*}} to <64 x i1>
80 // LLVM: [[RES:%.*]] = shufflevector <64 x i1> [[VAL]], <64 x i1> zeroinitializer, <64 x i32> <i32 32, i32 33, i32 34, i32 35, i32 36, i32 37, i32 38, i32 39, i32 40, i32 41, i32 42, i32 43, i32 44, i32 45, i32 46, i32 47, i32 48, i32 49, i32 50, i32 51, i32 52, i32 53, i32 54, i32 55, i32 56, i32 57, i32 58, i32 59, i32 60, i32 61, i32 62, i32 63, i32 64, i32 65, i32 66, i32 67, i32 68, i32 69, i32 70, i32 71, i32 72, i32 73, i32 74, i32 75, i32 76, i32 77, i32 78, i32 79, i32 80, i32 81, i32 82, i32 83, i32 84, i32 85, i32 86, i32 87, i32 88, i32 89, i32 90, i32 91, i32 92, i32 93, i32 94, i32 95>
81
82 // OGCG-LABEL: test_kshiftri_mask64
83 // OGCG: [[VAL:%.*]] = bitcast i64 %{{.*}} to <64 x i1>
84 // OGCG: [[RES:%.*]] = shufflevector <64 x i1> [[VAL]], <64 x i1> zeroinitializer, <64 x i32> <i32 32, i32 33, i32 34, i32 35, i32 36, i32 37, i32 38, i32 39, i32 40, i32 41, i32 42, i32 43, i32 44, i32 45, i32 46, i32 47, i32 48, i32 49, i32 50, i32 51, i32 52, i32 53, i32 54, i32 55, i32 56, i32 57, i32 58, i32 59, i32 60, i32 61, i32 62, i32 63, i32 64, i32 65, i32 66, i32 67, i32 68, i32 69, i32 70, i32 71, i32 72, i32 73, i32 74, i32 75, i32 76, i32 77, i32 78, i32 79, i32 80, i32 81, i32 82, i32 83, i32 84, i32 85, i32 86, i32 87, i32 88, i32 89, i32 90, i32 91, i32 92, i32 93, i32 94, i32 95>
85 return _kshiftri_mask64(A, 32);
86 }
87
88 __mmask32 test_kshiftli_mask32_out_of_range(__mmask32 A) {
89 // CIR-LABEL: test_kshiftli_mask32_out_of_range
90 // CIR: [[VAL:%.*]] = cir.const #cir.int<0> : !u32i
91 // CIR: cir.store [[VAL]], {{%.*}} : !u32i, !cir.ptr<!u32i>
92 // CIR: [[RES:%.*]] = cir.load {{%.*}} : !cir.ptr<!u32i>, !u32i
93 // CIR: cir.return [[RES]] : !u32i
94
95 // LLVM-LABEL: test_kshiftli_mask32_out_of_range
96 // LLVM: store i32 0, ptr [[VAL:%.*]], align 4
97 // LLVM: [[RES:%.*]] = load i32, ptr [[VAL]], align 4
98 // LLVM: ret i32 [[RES]]
99
100 // OGCG-LABEL: test_kshiftli_mask32_out_of_range
101 // OGCG: ret i32 0
102
103 return _kshiftli_mask32(A, 33);
104 }
105
106 __mmask32 test_kshiftri_mask32_out_of_range(__mmask32 A) {
107 // CIR-LABEL: test_kshiftri_mask32_out_of_range
108 // CIR: [[VAL:%.*]] = cir.const #cir.int<0> : !u32i
109 // CIR: cir.store [[VAL]], {{%.*}} : !u32i, !cir.ptr<!u32i>
110 // CIR: [[RES:%.*]] = cir.load {{%.*}} : !cir.ptr<!u32i>, !u32i
111 // CIR: cir.return [[RES]] : !u32i
112
113 // LLVM-LABEL: test_kshiftri_mask32_out_of_range
114 // LLVM: store i32 0, ptr [[VAL:%.*]], align 4
115 // LLVM: [[RES:%.*]] = load i32, ptr [[VAL]], align 4
116 // LLVM: ret i32 [[RES]]
117
118 // OGCG-LABEL: test_kshiftri_mask32_out_of_range
119 // OGCG: ret i32 0
120
121 return _kshiftri_mask32(A, 33);
122 }
123
124 __mmask32 test_kadd_mask32(__mmask32 A, __mmask32 B) {
125 // CIR-LABEL: _kadd_mask32
126 // CIR: cir.cast bitcast {{.*}} : !u32i -> !cir.vector<32 x !cir.int<s, 1>>
127 // CIR: cir.cast bitcast {{.*}} : !u32i -> !cir.vector<32 x !cir.int<s, 1>>
128 // CIR: cir.call_llvm_intrinsic "x86.avx512.kadd.d"
129 // CIR: cir.cast bitcast {{.*}} : !cir.vector<32 x !cir.int<s, 1>> -> !u32i
130
131 // LLVM-LABEL: _kadd_mask32
132 // LLVM: [[L:%.*]] = bitcast i32 %{{.*}} to <32 x i1>
133 // LLVM: [[R:%.*]] = bitcast i32 %{{.*}} to <32 x i1>
134 // LLVM: [[RES:%.*]] = call <32 x i1> @llvm.x86.avx512.kadd.d(<32 x i1> [[L]], <32 x i1> [[R]])
135 // LLVM: bitcast <32 x i1> [[RES]] to i32
136
137 // OGCG-LABEL: _kadd_mask32
138 // OGCG: bitcast i32 %{{.*}} to <32 x i1>
139 // OGCG: bitcast i32 %{{.*}} to <32 x i1>
140 // OGCG: call <32 x i1> @llvm.x86.avx512.kadd.d
141 // OGCG: bitcast <32 x i1> {{.*}} to i32
142 return _kadd_mask32(A, B);
143 }
144
145 __mmask64 test_kadd_mask64(__mmask64 A, __mmask64 B) {
146 // CIR-LABEL: _kadd_mask64
147 // CIR: cir.cast bitcast {{.*}} : !u64i -> !cir.vector<64 x !cir.int<s, 1>>
148 // CIR: cir.cast bitcast {{.*}} : !u64i -> !cir.vector<64 x !cir.int<s, 1>>
149 // CIR: cir.call_llvm_intrinsic "x86.avx512.kadd.q"
150 // CIR: cir.cast bitcast {{.*}} : !cir.vector<64 x !cir.int<s, 1>> -> !u64i
151
152 // LLVM-LABEL: _kadd_mask64
153 // LLVM: [[L:%.*]] = bitcast i64 %{{.*}} to <64 x i1>
154 // LLVM: [[R:%.*]] = bitcast i64 %{{.*}} to <64 x i1>
155 // LLVM: [[RES:%.*]] = call <64 x i1> @llvm.x86.avx512.kadd.q(<64 x i1> [[L]], <64 x i1> [[R]])
156 // LLVM: bitcast <64 x i1> [[RES]] to i64
157
158 // OGCG-LABEL: _kadd_mask64
159 // OGCG: bitcast i64 %{{.*}} to <64 x i1>
160 // OGCG: bitcast i64 %{{.*}} to <64 x i1>
161 // OGCG: call <64 x i1> @llvm.x86.avx512.kadd.q
162 // OGCG: bitcast <64 x i1> {{.*}} to i64
163 return _kadd_mask64(A, B);
164 }
165
166 __mmask32 test_kand_mask32(__mmask32 A, __mmask32 B) {
167 // CIR-LABEL: _kand_mask32
168 // CIR: cir.cast bitcast {{.*}} : !u32i -> !cir.vector<32 x !cir.int<s, 1>>
169 // CIR: cir.cast bitcast {{.*}} : !u32i -> !cir.vector<32 x !cir.int<s, 1>>
170 // CIR: cir.binop(and, {{.*}}, {{.*}}) : !cir.vector<32 x !cir.int<s, 1>>
171 // CIR: cir.cast bitcast {{.*}} : !cir.vector<32 x !cir.int<s, 1>> -> !u32i
172
173 // LLVM-LABEL: _kand_mask32
174 // LLVM: [[L:%.*]] = bitcast i32 %{{.*}} to <32 x i1>
175 // LLVM: [[R:%.*]] = bitcast i32 %{{.*}} to <32 x i1>
176 // LLVM: [[RES:%.*]] = and <32 x i1> [[L]], [[R]]
177 // LLVM: bitcast <32 x i1> [[RES]] to i32
178
179 // OGCG-LABEL: _kand_mask32
180 // OGCG: bitcast i32 %{{.*}} to <32 x i1>
181 // OGCG: bitcast i32 %{{.*}} to <32 x i1>
182 // OGCG: and <32 x i1>
183 // OGCG: bitcast <32 x i1> {{.*}} to i32
184 return _kand_mask32(A, B);
185 }
186
187 __mmask64 test_kand_mask64(__mmask64 A, __mmask64 B) {
188 // CIR-LABEL: _kand_mask64
189 // CIR: cir.cast bitcast {{.*}} : !u64i -> !cir.vector<64 x !cir.int<s, 1>>
190 // CIR: cir.cast bitcast {{.*}} : !u64i -> !cir.vector<64 x !cir.int<s, 1>>
191 // CIR: cir.binop(and, {{.*}}, {{.*}}) : !cir.vector<64 x !cir.int<s, 1>>
192 // CIR: cir.cast bitcast {{.*}} : !cir.vector<64 x !cir.int<s, 1>> -> !u64i
193
194 // LLVM-LABEL: _kand_mask64
195 // LLVM: [[L:%.*]] = bitcast i64 %{{.*}} to <64 x i1>
196 // LLVM: [[R:%.*]] = bitcast i64 %{{.*}} to <64 x i1>
197 // LLVM: [[RES:%.*]] = and <64 x i1> [[L]], [[R]]
198 // LLVM: bitcast <64 x i1> [[RES]] to i64
199
200 // OGCG-LABEL: _kand_mask64
201 // OGCG: bitcast i64 %{{.*}} to <64 x i1>
202 // OGCG: bitcast i64 %{{.*}} to <64 x i1>
203 // OGCG: and <64 x i1>
204 // OGCG: bitcast <64 x i1> {{.*}} to i64
205 return _kand_mask64(A, B);
206 }
207
208 __mmask32 test_kandn_mask32(__mmask32 A, __mmask32 B) {
209 // CIR-LABEL: _kandn_mask32
210 // CIR: cir.cast bitcast {{.*}} : !u32i -> !cir.vector<32 x !cir.int<s, 1>>
211 // CIR: cir.cast bitcast {{.*}} : !u32i -> !cir.vector<32 x !cir.int<s, 1>>
212 // CIR: cir.unary(not, {{.*}}) : !cir.vector<32 x !cir.int<s, 1>>
213 // CIR: cir.binop(and, {{.*}}, {{.*}}) : !cir.vector<32 x !cir.int<s, 1>>
214 // CIR: cir.cast bitcast {{.*}} : !cir.vector<32 x !cir.int<s, 1>> -> !u32i
215
216 // LLVM-LABEL: _kandn_mask32
217 // LLVM: [[L:%.*]] = bitcast i32 %{{.*}} to <32 x i1>
218 // LLVM: [[R:%.*]] = bitcast i32 %{{.*}} to <32 x i1>
219 // LLVM: xor <32 x i1> [[L]], splat (i1 true)
220 // LLVM: and <32 x i1>
221 // LLVM: bitcast <32 x i1> {{.*}} to i32
222
223 // OGCG-LABEL: _kandn_mask32
224 // OGCG: bitcast i32 %{{.*}} to <32 x i1>
225 // OGCG: bitcast i32 %{{.*}} to <32 x i1>
226 // OGCG: xor <32 x i1>
227 // OGCG: and <32 x i1>
228 // OGCG: bitcast <32 x i1> {{.*}} to i32
229 return _kandn_mask32(A, B);
230 }
231
232 __mmask64 test_kandn_mask64(__mmask64 A, __mmask64 B) {
233 // CIR-LABEL: _kandn_mask64
234 // CIR: cir.cast bitcast {{.*}} : !u64i -> !cir.vector<64 x !cir.int<s, 1>>
235 // CIR: cir.cast bitcast {{.*}} : !u64i -> !cir.vector<64 x !cir.int<s, 1>>
236 // CIR: cir.unary(not, {{.*}}) : !cir.vector<64 x !cir.int<s, 1>>
237 // CIR: cir.binop(and, {{.*}}, {{.*}}) : !cir.vector<64 x !cir.int<s, 1>>
238 // CIR: cir.cast bitcast {{.*}} : !cir.vector<64 x !cir.int<s, 1>> -> !u64i
239
240 // LLVM-LABEL: _kandn_mask64
241 // LLVM: [[L:%.*]] = bitcast i64 %{{.*}} to <64 x i1>
242 // LLVM: [[R:%.*]] = bitcast i64 %{{.*}} to <64 x i1>
243 // LLVM: xor <64 x i1> [[L]], splat (i1 true)
244 // LLVM: and <64 x i1>
245 // LLVM: bitcast <64 x i1> {{.*}} to i64
246
247 // OGCG-LABEL: _kandn_mask64
248 // OGCG: bitcast i64 %{{.*}} to <64 x i1>
249 // OGCG: bitcast i64 %{{.*}} to <64 x i1>
250 // OGCG: xor <64 x i1>
251 // OGCG: and <64 x i1>
252 // OGCG: bitcast <64 x i1> {{.*}} to i64
253 return _kandn_mask64(A, B);
254 }
255
256 __mmask32 test_kor_mask32(__mmask32 A, __mmask32 B) {
257 // CIR-LABEL: _kor_mask32
258 // CIR: cir.cast bitcast {{.*}} : !u32i -> !cir.vector<32 x !cir.int<s, 1>>
259 // CIR: cir.cast bitcast {{.*}} : !u32i -> !cir.vector<32 x !cir.int<s, 1>>
260 // CIR: cir.binop(or, {{.*}}, {{.*}}) : !cir.vector<32 x !cir.int<s, 1>>
261 // CIR: cir.cast bitcast {{.*}} : !cir.vector<32 x !cir.int<s, 1>> -> !u32i
262
263 // LLVM-LABEL: _kor_mask32
264 // LLVM: [[L:%.*]] = bitcast i32 %{{.*}} to <32 x i1>
265 // LLVM: [[R:%.*]] = bitcast i32 %{{.*}} to <32 x i1>
266 // LLVM: or <32 x i1> [[L]], [[R]]
267 // LLVM: bitcast <32 x i1> {{.*}} to i32
268
269 // OGCG-LABEL: _kor_mask32
270 // OGCG: bitcast i32 %{{.*}} to <32 x i1>
271 // OGCG: bitcast i32 %{{.*}} to <32 x i1>
272 // OGCG: or <32 x i1>
273 // OGCG: bitcast <32 x i1> {{.*}} to i32
274 return _kor_mask32(A, B);
275 }
276
277 __mmask64 test_kor_mask64(__mmask64 A, __mmask64 B) {
278 // CIR-LABEL: _kor_mask64
279 // CIR: cir.cast bitcast {{.*}} : !u64i -> !cir.vector<64 x !cir.int<s, 1>>
280 // CIR: cir.cast bitcast {{.*}} : !u64i -> !cir.vector<64 x !cir.int<s, 1>>
281 // CIR: cir.binop(or, {{.*}}, {{.*}}) : !cir.vector<64 x !cir.int<s, 1>>
282 // CIR: cir.cast bitcast {{.*}} : !cir.vector<64 x !cir.int<s, 1>> -> !u64i
283
284 // LLVM-LABEL: _kor_mask64
285 // LLVM: [[L:%.*]] = bitcast i64 %{{.*}} to <64 x i1>
286 // LLVM: [[R:%.*]] = bitcast i64 %{{.*}} to <64 x i1>
287 // LLVM: or <64 x i1> [[L]], [[R]]
288 // LLVM: bitcast <64 x i1> {{.*}} to i64
289
290 // OGCG-LABEL: _kor_mask64
291 // OGCG: bitcast i64 %{{.*}} to <64 x i1>
292 // OGCG: bitcast i64 %{{.*}} to <64 x i1>
293 // OGCG: or <64 x i1>
294 // OGCG: bitcast <64 x i1> {{.*}} to i64
295 return _kor_mask64(A, B);
296 }
297
298 __mmask32 test_kxor_mask32(__mmask32 A, __mmask32 B) {
299 // CIR-LABEL: _kxor_mask32
300 // CIR: cir.cast bitcast {{.*}} : !u32i -> !cir.vector<32 x !cir.int<s, 1>>
301 // CIR: cir.cast bitcast {{.*}} : !u32i -> !cir.vector<32 x !cir.int<s, 1>>
302 // CIR: cir.binop(xor, {{.*}}, {{.*}}) : !cir.vector<32 x !cir.int<s, 1>>
303 // CIR: cir.cast bitcast {{.*}} : !cir.vector<32 x !cir.int<s, 1>> -> !u32i
304
305 // LLVM-LABEL: _kxor_mask32
306 // LLVM: [[L:%.*]] = bitcast i32 %{{.*}} to <32 x i1>
307 // LLVM: [[R:%.*]] = bitcast i32 %{{.*}} to <32 x i1>
308 // LLVM: xor <32 x i1> [[L]], [[R]]
309 // LLVM: bitcast <32 x i1> {{.*}} to i32
310
311 // OGCG-LABEL: _kxor_mask32
312 // OGCG: bitcast i32 %{{.*}} to <32 x i1>
313 // OGCG: bitcast i32 %{{.*}} to <32 x i1>
314 // OGCG: xor <32 x i1>
315 // OGCG: bitcast <32 x i1> {{.*}} to i32
316 return _kxor_mask32(A, B);
317 }
318
319 __mmask64 test_kxor_mask64(__mmask64 A, __mmask64 B) {
320 // CIR-LABEL: _kxor_mask64
321 // CIR: cir.cast bitcast {{.*}} : !u64i -> !cir.vector<64 x !cir.int<s, 1>>
322 // CIR: cir.cast bitcast {{.*}} : !u64i -> !cir.vector<64 x !cir.int<s, 1>>
323 // CIR: cir.binop(xor, {{.*}}, {{.*}}) : !cir.vector<64 x !cir.int<s, 1>>
324 // CIR: cir.cast bitcast {{.*}} : !cir.vector<64 x !cir.int<s, 1>> -> !u64i
325
326 // LLVM-LABEL: _kxor_mask64
327 // LLVM: [[L:%.*]] = bitcast i64 %{{.*}} to <64 x i1>
328 // LLVM: [[R:%.*]] = bitcast i64 %{{.*}} to <64 x i1>
329 // LLVM: xor <64 x i1> [[L]], [[R]]
330 // LLVM: bitcast <64 x i1> {{.*}} to i64
331
332 // OGCG-LABEL: _kxor_mask64
333 // OGCG: bitcast i64 %{{.*}} to <64 x i1>
334 // OGCG: bitcast i64 %{{.*}} to <64 x i1>
335 // OGCG: xor <64 x i1>
336 // OGCG: bitcast <64 x i1> {{.*}} to i64
337 return _kxor_mask64(A, B);
338 }
339
340 __mmask32 test_kxnor_mask32(__mmask32 A, __mmask32 B) {
341 // CIR-LABEL: _kxnor_mask32
342 // CIR: cir.cast bitcast {{.*}} : !u32i -> !cir.vector<32 x !cir.int<s, 1>>
343 // CIR: cir.cast bitcast {{.*}} : !u32i -> !cir.vector<32 x !cir.int<s, 1>>
344 // CIR: cir.unary(not, {{.*}}) : !cir.vector<32 x !cir.int<s, 1>>
345 // CIR: cir.binop(xor, {{.*}}, {{.*}}) : !cir.vector<32 x !cir.int<s, 1>>
346 // CIR: cir.cast bitcast {{.*}} : !cir.vector<32 x !cir.int<s, 1>> -> !u32i
347
348 // LLVM-LABEL: _kxnor_mask32
349 // LLVM: [[L:%.*]] = bitcast i32 %{{.*}} to <32 x i1>
350 // LLVM: [[R:%.*]] = bitcast i32 %{{.*}} to <32 x i1>
351 // LLVM: [[NOT:%.*]] = xor <32 x i1> [[L]], splat (i1 true)
352 // LLVM: [[RES:%.*]] = xor <32 x i1> [[NOT]], [[R]]
353 // LLVM: bitcast <32 x i1> [[RES]] to i32
354
355 // OGCG-LABEL: _kxnor_mask32
356 // OGCG: bitcast i32 %{{.*}} to <32 x i1>
357 // OGCG: bitcast i32 %{{.*}} to <32 x i1>
358 // OGCG: xor <32 x i1>
359 // OGCG: xor <32 x i1>
360 // OGCG: bitcast <32 x i1> {{.*}} to i32
361
362 return _kxnor_mask32(A, B);
363 }
364
365 __mmask64 test_kxnor_mask64(__mmask64 A, __mmask64 B) {
366 // CIR-LABEL: _kxnor_mask64
367 // CIR: cir.cast bitcast {{.*}} : !u64i -> !cir.vector<64 x !cir.int<s, 1>>
368 // CIR: cir.cast bitcast {{.*}} : !u64i -> !cir.vector<64 x !cir.int<s, 1>>
369 // CIR: cir.unary(not, {{.*}}) : !cir.vector<64 x !cir.int<s, 1>>
370 // CIR: cir.binop(xor, {{.*}}, {{.*}}) : !cir.vector<64 x !cir.int<s, 1>>
371 // CIR: cir.cast bitcast {{.*}} : !cir.vector<64 x !cir.int<s, 1>> -> !u64i
372
373 // LLVM-LABEL: _kxnor_mask64
374 // LLVM: [[L:%.*]] = bitcast i64 %{{.*}} to <64 x i1>
375 // LLVM: [[R:%.*]] = bitcast i64 %{{.*}} to <64 x i1>
376 // LLVM: [[NOT:%.*]] = xor <64 x i1> [[L]], splat (i1 true)
377 // LLVM: [[RES:%.*]] = xor <64 x i1> [[NOT]], [[R]]
378 // LLVM: bitcast <64 x i1> [[RES]] to i64
379
380 // OGCG-LABEL: _kxnor_mask64
381 // OGCG: bitcast i64 %{{.*}} to <64 x i1>
382 // OGCG: bitcast i64 %{{.*}} to <64 x i1>
383 // OGCG: xor <64 x i1>
384 // OGCG: xor <64 x i1>
385 // OGCG: bitcast <64 x i1> {{.*}} to i64
386
387 return _kxnor_mask64(A, B);
388 }
389
390
391 __mmask32 test_knot_mask32(__mmask32 A) {
392 // CIR-LABEL: _knot_mask32
393 // CIR: cir.cast bitcast {{.*}} : !u32i -> !cir.vector<32 x !cir.int<s, 1>>
394 // CIR: cir.unary(not, {{.*}}) : !cir.vector<32 x !cir.int<s, 1>>
395 // CIR: cir.cast bitcast {{.*}} : !cir.vector<32 x !cir.int<s, 1>> -> !u32i
396
397 // LLVM-LABEL: _knot_mask32
398 // LLVM: bitcast i32 %{{.*}} to <32 x i1>
399 // LLVM: xor <32 x i1>
400 // LLVM: bitcast <32 x i1> {{.*}} to i32
401
402 // OGCG-LABEL: _knot_mask32
403 // OGCG: bitcast i32 %{{.*}} to <32 x i1>
404 // OGCG: xor <32 x i1>
405 // OGCG: bitcast <32 x i1> {{.*}} to i32
406 return _knot_mask32(A);
407 }
408
409 __mmask64 test_knot_mask64(__mmask64 A) {
410 // CIR-LABEL: _knot_mask64
411 // CIR: cir.cast bitcast {{.*}} : !u64i -> !cir.vector<64 x !cir.int<s, 1>>
412 // CIR: cir.unary(not, {{.*}}) : !cir.vector<64 x !cir.int<s, 1>>
413 // CIR: cir.cast bitcast {{.*}} : !cir.vector<64 x !cir.int<s, 1>> -> !u64i
414
415 // LLVM-LABEL: _knot_mask64
416 // LLVM: bitcast i64 %{{.*}} to <64 x i1>
417 // LLVM: xor <64 x i1>
418 // LLVM: bitcast <64 x i1> {{.*}} to i64
419
420 // OGCG-LABEL: _knot_mask64
421 // OGCG: bitcast i64 %{{.*}} to <64 x i1>
422 // OGCG: xor <64 x i1>
423 // OGCG: bitcast <64 x i1> {{.*}} to i64
424 return _knot_mask64(A);
425 }
426
427 // Multiple user-level mask helpers inline to this same kmov builtin.
428 // CIR does not implement any special lowering for those helpers.
429 //
430 // Therefore, testing the builtin (__builtin_ia32_kmov*) directly is
431 // sufficient to cover the CIR lowering behavior. Testing each helper
432 // individually would add no new CIR paths.
433
434 __mmask32 test_kmov_d(__mmask32 A) {
435 // CIR-LABEL: test_kmov_d
436 // CIR: cir.cast bitcast {{.*}} : !u32i -> !cir.vector<32 x !cir.int<s, 1>>
437 // CIR: cir.cast bitcast {{.*}} : !cir.vector<32 x !cir.int<s, 1>> -> !u32i
438
439 // LLVM-LABEL: test_kmov_d
440 // LLVM: bitcast i32 %{{.*}} to <32 x i1>
441 // LLVM: bitcast <32 x i1> {{.*}} to i32
442
443 // OGCG-LABEL: test_kmov_d
444 // OGCG: bitcast i32 %{{.*}} to <32 x i1>
445 // OGCG: bitcast <32 x i1> {{.*}} to i32
446
447 return __builtin_ia32_kmovd(A);
448 }
449
450 // Multiple user-level mask helpers inline to this same kmov builtin.
451 // CIR does not implement any special lowering for those helpers.
452 //
453 // Therefore, testing the builtin (__builtin_ia32_kmov*) directly is
454 // sufficient to cover the CIR lowering behavior. Testing each helper
455 // individually would add no new CIR paths.
456
457 __mmask64 test_kmov_q(__mmask64 A) {
458 // CIR-LABEL: test_kmov_q
459 // CIR: cir.cast bitcast {{.*}} : !u64i -> !cir.vector<64 x !cir.int<s, 1>>
460 // CIR: cir.cast bitcast {{.*}} : !cir.vector<64 x !cir.int<s, 1>> -> !u64i
461
462 // LLVM-LABEL: test_kmov_q
463 // LLVM: bitcast i64 %{{.*}} to <64 x i1>
464 // LLVM: bitcast <64 x i1> {{.*}} to i64
465
466 // OGCG-LABEL: test_kmov_q
467 // OGCG: bitcast i64 %{{.*}} to <64 x i1>
468 // OGCG: bitcast <64 x i1> {{.*}} to i64
469
470 return __builtin_ia32_kmovq(A);
471 }
472
473 __mmask32 test_mm512_kunpackw(__mmask32 A, __mmask32 B) {
474 // CIR-LABEL: _mm512_kunpackw
475 // CIR: cir.cast bitcast {{.*}} : !u32i -> !cir.vector<32 x !cir.int<s, 1>>
476 // CIR: cir.cast bitcast {{.*}} : !u32i -> !cir.vector<32 x !cir.int<s, 1>>
477 // CIR: cir.vec.shuffle
478 // CIR: cir.vec.shuffle
479 // CIR: cir.vec.shuffle
480 // CIR: cir.cast bitcast {{.*}} : !cir.vector<32 x !cir.int<s, 1>> -> !u32i
481
482 // LLVM-LABEL: _mm512_kunpackw
483 // LLVM: [[A_VEC:%.*]] = bitcast i32 %{{.*}} to <32 x i1>
484 // LLVM: [[B_VEC:%.*]] = bitcast i32 %{{.*}} to <32 x i1>
485 // LLVM: [[A_HALF:%.*]] = shufflevector <32 x i1> [[A_VEC]], <32 x i1> [[A_VEC]], <16 x i32> <i32 0, i32 1, i32 2, i32 3, i32 4, i32 5, i32 6, i32 7, i32 8, i32 9, i32 10, i32 11, i32 12, i32 13, i32 14, i32 15>
486 // LLVM: [[B_HALF:%.*]] = shufflevector <32 x i1> [[B_VEC]], <32 x i1> [[B_VEC]], <16 x i32> <i32 0, i32 1, i32 2, i32 3, i32 4, i32 5, i32 6, i32 7, i32 8, i32 9, i32 10, i32 11, i32 12, i32 13, i32 14, i32 15>
487 // LLVM: [[RES:%.*]] = shufflevector <16 x i1> [[B_HALF]], <16 x i1> [[A_HALF]], <32 x i32> <i32 0, i32 1, i32 2, i32 3, i32 4, i32 5, i32 6, i32 7, i32 8, i32 9, i32 10, i32 11, i32 12, i32 13, i32 14, i32 15, i32 16, i32 17, i32 18, i32 19, i32 20, i32 21, i32 22, i32 23, i32 24, i32 25, i32 26, i32 27, i32 28, i32 29, i32 30, i32 31>
488 // LLVM: bitcast <32 x i1> [[RES]] to i32
489
490 // OGCG-LABEL: _mm512_kunpackw
491 // OGCG: [[A_VEC:%.*]] = bitcast i32 %{{.*}} to <32 x i1>
492 // OGCG: [[B_VEC:%.*]] = bitcast i32 %{{.*}} to <32 x i1>
493 // OGCG: [[A_HALF:%.*]] = shufflevector <32 x i1> [[A_VEC]], <32 x i1> [[A_VEC]], <16 x i32> <i32 0, i32 1, i32 2, i32 3, i32 4, i32 5, i32 6, i32 7, i32 8, i32 9, i32 10, i32 11, i32 12, i32 13, i32 14, i32 15>
494 // OGCG: [[B_HALF:%.*]] = shufflevector <32 x i1> [[B_VEC]], <32 x i1> [[B_VEC]], <16 x i32> <i32 0, i32 1, i32 2, i32 3, i32 4, i32 5, i32 6, i32 7, i32 8, i32 9, i32 10, i32 11, i32 12, i32 13, i32 14, i32 15>
495 // OGCG: [[RES:%.*]] = shufflevector <16 x i1> [[B_HALF]], <16 x i1> [[A_HALF]], <32 x i32> <i32 0, i32 1, i32 2, i32 3, i32 4, i32 5, i32 6, i32 7, i32 8, i32 9, i32 10, i32 11, i32 12, i32 13, i32 14, i32 15, i32 16, i32 17, i32 18, i32 19, i32 20, i32 21, i32 22, i32 23, i32 24, i32 25, i32 26, i32 27, i32 28, i32 29, i32 30, i32 31>
496 // OGCG: bitcast <32 x i1> [[RES]] to i32
497 return _mm512_kunpackw(A, B);
498 }
499
500 __mmask64 test_mm512_kunpackd(__mmask64 A, __mmask64 B) {
501 // CIR-LABEL: _mm512_kunpackd
502 // CIR: cir.cast bitcast {{.*}} : !u64i -> !cir.vector<64 x !cir.int<s, 1>>
503 // CIR: cir.cast bitcast {{.*}} : !u64i -> !cir.vector<64 x !cir.int<s, 1>>
504 // CIR: cir.vec.shuffle
505 // CIR: cir.vec.shuffle
506 // CIR: cir.vec.shuffle
507 // CIR: cir.cast bitcast {{.*}} : !cir.vector<64 x !cir.int<s, 1>> -> !u64i
508
509 // LLVM-LABEL: _mm512_kunpackd
510 // LLVM: [[A_VEC:%.*]] = bitcast i64 %{{.*}} to <64 x i1>
511 // LLVM: [[B_VEC:%.*]] = bitcast i64 %{{.*}} to <64 x i1>
512 // LLVM: [[A_HALF:%.*]] = shufflevector <64 x i1> [[A_VEC]], <64 x i1> [[A_VEC]], <32 x i32> <i32 0, i32 1, i32 2, i32 3, i32 4, i32 5, i32 6, i32 7, i32 8, i32 9, i32 10, i32 11, i32 12, i32 13, i32 14, i32 15, i32 16, i32 17, i32 18, i32 19, i32 20, i32 21, i32 22, i32 23, i32 24, i32 25, i32 26, i32 27, i32 28, i32 29, i32 30, i32 31>
513 // LLVM: [[B_HALF:%.*]] = shufflevector <64 x i1> [[B_VEC]], <64 x i1> [[B_VEC]], <32 x i32> <i32 0, i32 1, i32 2, i32 3, i32 4, i32 5, i32 6, i32 7, i32 8, i32 9, i32 10, i32 11, i32 12, i32 13, i32 14, i32 15, i32 16, i32 17, i32 18, i32 19, i32 20, i32 21, i32 22, i32 23, i32 24, i32 25, i32 26, i32 27, i32 28, i32 29, i32 30, i32 31>
514 // LLVM: [[RES:%.*]] = shufflevector <32 x i1> [[B_HALF]], <32 x i1> [[A_HALF]], <64 x i32> <i32 0, i32 1, i32 2, i32 3, i32 4, i32 5, i32 6, i32 7, i32 8, i32 9, i32 10, i32 11, i32 12, i32 13, i32 14, i32 15, i32 16, i32 17, i32 18, i32 19, i32 20, i32 21, i32 22, i32 23, i32 24, i32 25, i32 26, i32 27, i32 28, i32 29, i32 30, i32 31, i32 32, i32 33, i32 34, i32 35, i32 36, i32 37, i32 38, i32 39, i32 40, i32 41, i32 42, i32 43, i32 44, i32 45, i32 46, i32 47, i32 48, i32 49, i32 50, i32 51, i32 52, i32 53, i32 54, i32 55, i32 56, i32 57, i32 58, i32 59, i32 60, i32 61, i32 62, i32 63>
515 // LLVM: bitcast <64 x i1> [[RES]] to i64
516
517 // OGCG-LABEL: _mm512_kunpackd
518 // OGCG: [[A_VEC:%.*]] = bitcast i64 %{{.*}} to <64 x i1>
519 // OGCG: [[B_VEC:%.*]] = bitcast i64 %{{.*}} to <64 x i1>
520 // OGCG: [[A_HALF:%.*]] = shufflevector <64 x i1> [[A_VEC]], <64 x i1> [[A_VEC]], <32 x i32> <i32 0, i32 1, i32 2, i32 3, i32 4, i32 5, i32 6, i32 7, i32 8, i32 9, i32 10, i32 11, i32 12, i32 13, i32 14, i32 15, i32 16, i32 17, i32 18, i32 19, i32 20, i32 21, i32 22, i32 23, i32 24, i32 25, i32 26, i32 27, i32 28, i32 29, i32 30, i32 31>
521 // OGCG: [[B_HALF:%.*]] = shufflevector <64 x i1> [[B_VEC]], <64 x i1> [[B_VEC]], <32 x i32> <i32 0, i32 1, i32 2, i32 3, i32 4, i32 5, i32 6, i32 7, i32 8, i32 9, i32 10, i32 11, i32 12, i32 13, i32 14, i32 15, i32 16, i32 17, i32 18, i32 19, i32 20, i32 21, i32 22, i32 23, i32 24, i32 25, i32 26, i32 27, i32 28, i32 29, i32 30, i32 31>
522 // OGCG: [[RES:%.*]] = shufflevector <32 x i1> [[B_HALF]], <32 x i1> [[A_HALF]], <64 x i32> <i32 0, i32 1, i32 2, i32 3, i32 4, i32 5, i32 6, i32 7, i32 8, i32 9, i32 10, i32 11, i32 12, i32 13, i32 14, i32 15, i32 16, i32 17, i32 18, i32 19, i32 20, i32 21, i32 22, i32 23, i32 24, i32 25, i32 26, i32 27, i32 28, i32 29, i32 30, i32 31, i32 32, i32 33, i32 34, i32 35, i32 36, i32 37, i32 38, i32 39, i32 40, i32 41, i32 42, i32 43, i32 44, i32 45, i32 46, i32 47, i32 48, i32 49, i32 50, i32 51, i32 52, i32 53, i32 54, i32 55, i32 56, i32 57, i32 58, i32 59, i32 60, i32 61, i32 62, i32 63>
523 // OGCG: bitcast <64 x i1> [[RES]] to i64
524 return _mm512_kunpackd(A, B);
525 }
526
527 __m512i test_mm512_shufflelo_epi16(__m512i __A) {
528 // CIR-LABEL: _mm512_shufflelo_epi16
529 // CIR: %{{.*}} = cir.vec.shuffle(%{{.*}}, %{{.*}} : !cir.vector<32 x !s16i>) [#cir.int<1> : !s32i, #cir.int<1> : !s32i, #cir.int<0> : !s32i, #cir.int<0> : !s32i, #cir.int<4> : !s32i, #cir.int<5> : !s32i, #cir.int<6> : !s32i, #cir.int<7> : !s32i, #cir.int<9> : !s32i, #cir.int<9> : !s32i, #cir.int<8> : !s32i, #cir.int<8> : !s32i, #cir.int<12> : !s32i, #cir.int<13> : !s32i, #cir.int<14> : !s32i, #cir.int<15> : !s32i, #cir.int<17> : !s32i, #cir.int<17> : !s32i, #cir.int<16> : !s32i, #cir.int<16> : !s32i, #cir.int<20> : !s32i, #cir.int<21> : !s32i, #cir.int<22> : !s32i, #cir.int<23> : !s32i, #cir.int<25> : !s32i, #cir.int<25> : !s32i, #cir.int<24> : !s32i, #cir.int<24> : !s32i, #cir.int<28> : !s32i, #cir.int<29> : !s32i, #cir.int<30> : !s32i, #cir.int<31> : !s32i] : !cir.vector<32 x !s16i>
530
531 // LLVM-LABEL: test_mm512_shufflelo_epi16
532 // LLVM: shufflevector <32 x i16> %{{.*}}, <32 x i16> poison, <32 x i32> <i32 1, i32 1, i32 0, i32 0, i32 4, i32 5, i32 6, i32 7, i32 9, i32 9, i32 8, i32 8, i32 12, i32 13, i32 14, i32 15, i32 17, i32 17, i32 16, i32 16, i32 20, i32 21, i32 22, i32 23, i32 25, i32 25, i32 24, i32 24, i32 28, i32 29, i32 30, i32 31>
533
534 // OGCG-LABEL: test_mm512_shufflelo_epi16
535 // OGCG: shufflevector <32 x i16> %{{.*}}, <32 x i16> poison, <32 x i32> <i32 1, i32 1, i32 0, i32 0, i32 4, i32 5, i32 6, i32 7, i32 9, i32 9, i32 8, i32 8, i32 12, i32 13, i32 14, i32 15, i32 17, i32 17, i32 16, i32 16, i32 20, i32 21, i32 22, i32 23, i32 25, i32 25, i32 24, i32 24, i32 28, i32 29, i32 30, i32 31>
536 return _mm512_shufflelo_epi16(__A, 5);
537 }
538
539 __m512i test_mm512_shufflehi_epi16(__m512i __A) {
540 // CIR-LABEL: _mm512_shufflehi_epi16
541 // CIR: %{{.*}} = cir.vec.shuffle(%{{.*}}, %{{.*}} : !cir.vector<32 x !s16i>) [#cir.int<0> : !s32i, #cir.int<1> : !s32i, #cir.int<2> : !s32i, #cir.int<3> : !s32i, #cir.int<5> : !s32i, #cir.int<5> : !s32i, #cir.int<4> : !s32i, #cir.int<4> : !s32i, #cir.int<8> : !s32i, #cir.int<9> : !s32i, #cir.int<10> : !s32i, #cir.int<11> : !s32i, #cir.int<13> : !s32i, #cir.int<13> : !s32i, #cir.int<12> : !s32i, #cir.int<12> : !s32i, #cir.int<16> : !s32i, #cir.int<17> : !s32i, #cir.int<18> : !s32i, #cir.int<19> : !s32i, #cir.int<21> : !s32i, #cir.int<21> : !s32i, #cir.int<20> : !s32i, #cir.int<20> : !s32i, #cir.int<24> : !s32i, #cir.int<25> : !s32i, #cir.int<26> : !s32i, #cir.int<27> : !s32i, #cir.int<29> : !s32i, #cir.int<29> : !s32i, #cir.int<28> : !s32i, #cir.int<28> : !s32i] : !cir.vector<32 x !s16i>
542
543 // LLVM-LABEL: test_mm512_shufflehi_epi16
544 // LLVM: shufflevector <32 x i16> %{{.*}}, <32 x i16> poison, <32 x i32> <i32 0, i32 1, i32 2, i32 3, i32 5, i32 5, i32 4, i32 4, i32 8, i32 9, i32 10, i32 11, i32 13, i32 13, i32 12, i32 12, i32 16, i32 17, i32 18, i32 19, i32 21, i32 21, i32 20, i32 20, i32 24, i32 25, i32 26, i32 27, i32 29, i32 29, i32 28, i32 28>
545
546 // OGCG-LABEL: test_mm512_shufflehi_epi16
547 // OGCG: shufflevector <32 x i16> %{{.*}}, <32 x i16> poison, <32 x i32> <i32 0, i32 1, i32 2, i32 3, i32 5, i32 5, i32 4, i32 4, i32 8, i32 9, i32 10, i32 11, i32 13, i32 13, i32 12, i32 12, i32 16, i32 17, i32 18, i32 19, i32 21, i32 21, i32 20, i32 20, i32 24, i32 25, i32 26, i32 27, i32 29, i32 29, i32 28, i32 28>
548 return _mm512_shufflehi_epi16(__A, 5);
549 }
550
551 unsigned char test_kortestc_mask32_u8(__mmask32 __A, __mmask32 __B) {
552 // CIR-LABEL: _kortestc_mask32_u8
553 // CIR: %[[ALL_ONES:.*]] = cir.const #cir.int<4294967295> : !u32i
554 // CIR: %[[LHS:.*]] = cir.cast bitcast {{.*}} : !u32i -> !cir.vector<32 x !cir.int<s, 1>>
555 // CIR: %[[RHS:.*]] = cir.cast bitcast {{.*}} : !u32i -> !cir.vector<32 x !cir.int<s, 1>>
556 // CIR: %[[OR:.*]] = cir.binop(or, %[[LHS]], %[[RHS]]) : !cir.vector<32 x !cir.int<s, 1>>
557 // CIR: %[[OR_INT:.*]] = cir.cast bitcast %[[OR]] : !cir.vector<32 x !cir.int<s, 1>> -> !u32i
558 // CIR: %[[CMP:.*]] = cir.cmp(eq, %[[OR_INT]], %[[ALL_ONES]]) : !u32i, !cir.bool
559 // CIR: %[[B2I:.*]] = cir.cast bool_to_int %[[CMP]] : !cir.bool -> !s32i
560 // CIR: cir.cast integral %[[B2I]] : !s32i -> !u8i
561
562 // LLVM-LABEL: _kortestc_mask32_u8
563 // LLVM: %[[LHS:.*]] = bitcast i32 %{{.*}} to <32 x i1>
564 // LLVM: %[[RHS:.*]] = bitcast i32 %{{.*}} to <32 x i1>
565 // LLVM: %[[OR:.*]] = or <32 x i1> %[[LHS]], %[[RHS]]
566 // LLVM: %[[CAST:.*]] = bitcast <32 x i1> %[[OR]] to i32
567 // LLVM: %[[CMP:.*]] = icmp eq i32 %[[CAST]], -1
568 // LLVM: %[[ZEXT:.*]] = zext i1 %[[CMP]] to i32
569 // LLVM: trunc i32 %[[ZEXT]] to i8
570
571 // OGCG-LABEL: _kortestc_mask32_u8
572 // OGCG: %[[LHS:.*]] = bitcast i32 %{{.*}} to <32 x i1>
573 // OGCG: %[[RHS:.*]] = bitcast i32 %{{.*}} to <32 x i1>
574 // OGCG: %[[OR:.*]] = or <32 x i1> %[[LHS]], %[[RHS]]
575 // OGCG: %[[CAST:.*]] = bitcast <32 x i1> %[[OR]] to i32
576 // OGCG: %[[CMP:.*]] = icmp eq i32 %[[CAST]], -1
577 // OGCG: %[[ZEXT:.*]] = zext i1 %[[CMP]] to i32
578 // OGCG: trunc i32 %[[ZEXT]] to i8
579 return _kortestc_mask32_u8(__A, __B);
580 }
581
582 unsigned char test_kortestc_mask64_u8(__mmask64 __A, __mmask64 __B) {
583 // CIR-LABEL: _kortestc_mask64_u8
584 // CIR: %[[ALL_ONES:.*]] = cir.const #cir.int<18446744073709551615> : !u64i
585 // CIR: %[[LHS:.*]] = cir.cast bitcast {{.*}} : !u64i -> !cir.vector<64 x !cir.int<s, 1>>
586 // CIR: %[[RHS:.*]] = cir.cast bitcast {{.*}} : !u64i -> !cir.vector<64 x !cir.int<s, 1>>
587 // CIR: %[[OR:.*]] = cir.binop(or, %[[LHS]], %[[RHS]]) : !cir.vector<64 x !cir.int<s, 1>>
588 // CIR: %[[OR_INT:.*]] = cir.cast bitcast %[[OR]] : !cir.vector<64 x !cir.int<s, 1>> -> !u64i
589 // CIR: %[[CMP:.*]] = cir.cmp(eq, %[[OR_INT]], %[[ALL_ONES]]) : !u64i, !cir.bool
590 // CIR: %[[B2I:.*]] = cir.cast bool_to_int %[[CMP]] : !cir.bool -> !s32i
591 // CIR: cir.cast integral %[[B2I]] : !s32i -> !u8i
592
593 // LLVM-LABEL: _kortestc_mask64_u8
594 // LLVM: %[[LHS:.*]] = bitcast i64 %{{.*}} to <64 x i1>
595 // LLVM: %[[RHS:.*]] = bitcast i64 %{{.*}} to <64 x i1>
596 // LLVM: %[[OR:.*]] = or <64 x i1> %[[LHS]], %[[RHS]]
597 // LLVM: %[[CAST:.*]] = bitcast <64 x i1> %[[OR]] to i64
598 // LLVM: %[[CMP:.*]] = icmp eq i64 %[[CAST]], -1
599 // LLVM: %[[ZEXT:.*]] = zext i1 %[[CMP]] to i32
600 // LLVM: trunc i32 %[[ZEXT]] to i8
601
602 // OGCG-LABEL: _kortestc_mask64_u8
603 // OGCG: %[[LHS:.*]] = bitcast i64 %{{.*}} to <64 x i1>
604 // OGCG: %[[RHS:.*]] = bitcast i64 %{{.*}} to <64 x i1>
605 // OGCG: %[[OR:.*]] = or <64 x i1> %[[LHS]], %[[RHS]]
606 // OGCG: %[[CAST:.*]] = bitcast <64 x i1> %[[OR]] to i64
607 // OGCG: %[[CMP:.*]] = icmp eq i64 %[[CAST]], -1
608 // OGCG: %[[ZEXT:.*]] = zext i1 %[[CMP]] to i32
609 // OGCG: trunc i32 %[[ZEXT]] to i8
610 return _kortestc_mask64_u8(__A, __B);
611 }
612
613 unsigned char test_kortestz_mask32_u8(__mmask32 __A, __mmask32 __B) {
614 // CIR-LABEL: _kortestz_mask32_u8
615 // CIR: %[[ZERO:.*]] = cir.const #cir.int<0> : !u32i
616 // CIR: %[[LHS:.*]] = cir.cast bitcast {{.*}} : !u32i -> !cir.vector<32 x !cir.int<s, 1>>
617 // CIR: %[[RHS:.*]] = cir.cast bitcast {{.*}} : !u32i -> !cir.vector<32 x !cir.int<s, 1>>
618 // CIR: %[[OR:.*]] = cir.binop(or, %[[LHS]], %[[RHS]]) : !cir.vector<32 x !cir.int<s, 1>>
619 // CIR: %[[OR_INT:.*]] = cir.cast bitcast %[[OR]] : !cir.vector<32 x !cir.int<s, 1>> -> !u32i
620 // CIR: %[[CMP:.*]] = cir.cmp(eq, %[[OR_INT]], %[[ZERO]]) : !u32i, !cir.bool
621 // CIR: %[[B2I:.*]] = cir.cast bool_to_int %[[CMP]] : !cir.bool -> !s32i
622 // CIR: cir.cast integral %[[B2I]] : !s32i -> !u8i
623
624 // LLVM-LABEL: _kortestz_mask32_u8
625 // LLVM: %[[LHS:.*]] = bitcast i32 %{{.*}} to <32 x i1>
626 // LLVM: %[[RHS:.*]] = bitcast i32 %{{.*}} to <32 x i1>
627 // LLVM: %[[OR:.*]] = or <32 x i1> %[[LHS]], %[[RHS]]
628 // LLVM: %[[CAST:.*]] = bitcast <32 x i1> %[[OR]] to i32
629 // LLVM: %[[CMP:.*]] = icmp eq i32 %[[CAST]], 0
630 // LLVM: %[[ZEXT:.*]] = zext i1 %[[CMP]] to i32
631 // LLVM: trunc i32 %[[ZEXT]] to i8
632
633 // OGCG-LABEL: _kortestz_mask32_u8
634 // OGCG: %[[LHS:.*]] = bitcast i32 %{{.*}} to <32 x i1>
635 // OGCG: %[[RHS:.*]] = bitcast i32 %{{.*}} to <32 x i1>
636 // OGCG: %[[OR:.*]] = or <32 x i1> %[[LHS]], %[[RHS]]
637 // OGCG: %[[CAST:.*]] = bitcast <32 x i1> %[[OR]] to i32
638 // OGCG: %[[CMP:.*]] = icmp eq i32 %[[CAST]], 0
639 // OGCG: %[[ZEXT:.*]] = zext i1 %[[CMP]] to i32
640 // OGCG: trunc i32 %[[ZEXT]] to i8
641 return _kortestz_mask32_u8(__A, __B);
642 }
643
644 unsigned char test_kortestz_mask64_u8(__mmask64 __A, __mmask64 __B) {
645 // CIR-LABEL: _kortestz_mask64_u8
646 // CIR: %[[ZERO:.*]] = cir.const #cir.int<0> : !u64i
647 // CIR: %[[LHS:.*]] = cir.cast bitcast {{.*}} : !u64i -> !cir.vector<64 x !cir.int<s, 1>>
648 // CIR: %[[RHS:.*]] = cir.cast bitcast {{.*}} : !u64i -> !cir.vector<64 x !cir.int<s, 1>>
649 // CIR: %[[OR:.*]] = cir.binop(or, %[[LHS]], %[[RHS]]) : !cir.vector<64 x !cir.int<s, 1>>
650 // CIR: %[[OR_INT:.*]] = cir.cast bitcast %[[OR]] : !cir.vector<64 x !cir.int<s, 1>> -> !u64i
651 // CIR: %[[CMP:.*]] = cir.cmp(eq, %[[OR_INT]], %[[ZERO]]) : !u64i, !cir.bool
652 // CIR: %[[B2I:.*]] = cir.cast bool_to_int %[[CMP]] : !cir.bool -> !s32i
653 // CIR: cir.cast integral %[[B2I]] : !s32i -> !u8i
654
655 // LLVM-LABEL: _kortestz_mask64_u8
656 // LLVM: %[[LHS:.*]] = bitcast i64 %{{.*}} to <64 x i1>
657 // LLVM: %[[RHS:.*]] = bitcast i64 %{{.*}} to <64 x i1>
658 // LLVM: %[[OR:.*]] = or <64 x i1> %[[LHS]], %[[RHS]]
659 // LLVM: %[[CAST:.*]] = bitcast <64 x i1> %[[OR]] to i64
660 // LLVM: %[[CMP:.*]] = icmp eq i64 %[[CAST]], 0
661 // LLVM: %[[ZEXT:.*]] = zext i1 %[[CMP]] to i32
662 // LLVM: trunc i32 %[[ZEXT]] to i8
663
664 // OGCG-LABEL: _kortestz_mask64_u8
665 // OGCG: %[[LHS:.*]] = bitcast i64 %{{.*}} to <64 x i1>
666 // OGCG: %[[RHS:.*]] = bitcast i64 %{{.*}} to <64 x i1>
667 // OGCG: %[[OR:.*]] = or <64 x i1> %[[LHS]], %[[RHS]]
668 // OGCG: %[[CAST:.*]] = bitcast <64 x i1> %[[OR]] to i64
669 // OGCG: %[[CMP:.*]] = icmp eq i64 %[[CAST]], 0
670 // OGCG: %[[ZEXT:.*]] = zext i1 %[[CMP]] to i32
671 // OGCG: trunc i32 %[[ZEXT]] to i8
672 return _kortestz_mask64_u8(__A, __B);
673 }
674
675 unsigned char test_ktestc_mask32_u8(__mmask32 A, __mmask32 B) {
676 // CIR-LABEL: _ktestc_mask32_u8
677 // CIR: %[[LHS:.*]] = cir.cast bitcast {{.*}} : !u32i -> !cir.vector<32 x !cir.int<s, 1>>
678 // CIR: %[[RHS:.*]] = cir.cast bitcast {{.*}} : !u32i -> !cir.vector<32 x !cir.int<s, 1>>
679 // CIR: %[[RES:.*]] = cir.call_llvm_intrinsic "x86.avx512.ktestc.d"
680 // CIR: cir.cast integral %[[RES]] : {{.*}} -> !u8i
681
682 // LLVM-LABEL: _ktestc_mask32_u8
683 // LLVM: %[[LHS:.*]] = bitcast i32 %{{.*}} to <32 x i1>
684 // LLVM: %[[RHS:.*]] = bitcast i32 %{{.*}} to <32 x i1>
685 // LLVM: %[[RES:.*]] = call i32 @llvm.x86.avx512.ktestc.d(<32 x i1> %[[LHS]], <32 x i1> %[[RHS]])
686 // LLVM: trunc i32 %[[RES]] to i8
687
688 // OGCG-LABEL: _ktestc_mask32_u8
689 // OGCG: %[[LHS:.*]] = bitcast i32 %{{.*}} to <32 x i1>
690 // OGCG: %[[RHS:.*]] = bitcast i32 %{{.*}} to <32 x i1>
691 // OGCG: %[[RES:.*]] = call i32 @llvm.x86.avx512.ktestc.d
692 // OGCG: trunc i32 %[[RES]] to i8
693 return _ktestc_mask32_u8(A, B);
694 }
695
696 unsigned char test_ktestz_mask32_u8(__mmask32 A, __mmask32 B) {
697 // CIR-LABEL: _ktestz_mask32_u8
698 // CIR: %[[LHS:.*]] = cir.cast bitcast {{.*}} : !u32i -> !cir.vector<32 x !cir.int<s, 1>>
699 // CIR: %[[RHS:.*]] = cir.cast bitcast {{.*}} : !u32i -> !cir.vector<32 x !cir.int<s, 1>>
700 // CIR: %[[RES:.*]] = cir.call_llvm_intrinsic "x86.avx512.ktestz.d"
701 // CIR: cir.cast integral %[[RES]] : {{.*}} -> !u8i
702
703 // LLVM-LABEL: _ktestz_mask32_u8
704 // LLVM: %[[LHS:.*]] = bitcast i32 %{{.*}} to <32 x i1>
705 // LLVM: %[[RHS:.*]] = bitcast i32 %{{.*}} to <32 x i1>
706 // LLVM: %[[RES:.*]] = call i32 @llvm.x86.avx512.ktestz.d(<32 x i1> %[[LHS]], <32 x i1> %[[RHS]])
707 // LLVM: trunc i32 %[[RES]] to i8
708
709 // OGCG-LABEL: _ktestz_mask32_u8
710 // OGCG: %[[LHS:.*]] = bitcast i32 %{{.*}} to <32 x i1>
711 // OGCG: %[[RHS:.*]] = bitcast i32 %{{.*}} to <32 x i1>
712 // OGCG: %[[RES:.*]] = call i32 @llvm.x86.avx512.ktestz.d
713 // OGCG: trunc i32 %[[RES]] to i8
714 return _ktestz_mask32_u8(A, B);
715 }
716
717 unsigned char test_ktestc_mask64_u8(__mmask64 A, __mmask64 B) {
718 // CIR-LABEL: _ktestc_mask64_u8
719 // CIR: %[[LHS:.*]] = cir.cast bitcast {{.*}} : !u64i -> !cir.vector<64 x !cir.int<s, 1>>
720 // CIR: %[[RHS:.*]] = cir.cast bitcast {{.*}} : !u64i -> !cir.vector<64 x !cir.int<s, 1>>
721 // CIR: %[[RES:.*]] = cir.call_llvm_intrinsic "x86.avx512.ktestc.q"
722 // CIR: cir.cast integral %[[RES]] : {{.*}} -> !u8i
723
724 // LLVM-LABEL: _ktestc_mask64_u8
725 // LLVM: %[[LHS:.*]] = bitcast i64 %{{.*}} to <64 x i1>
726 // LLVM: %[[RHS:.*]] = bitcast i64 %{{.*}} to <64 x i1>
727 // LLVM: %[[RES:.*]] = call i32 @llvm.x86.avx512.ktestc.q(<64 x i1> %[[LHS]], <64 x i1> %[[RHS]])
728 // LLVM: trunc i32 %[[RES]] to i8
729
730 // OGCG-LABEL: _ktestc_mask64_u8
731 // OGCG: %[[LHS:.*]] = bitcast i64 %{{.*}} to <64 x i1>
732 // OGCG: %[[RHS:.*]] = bitcast i64 %{{.*}} to <64 x i1>
733 // OGCG: %[[RES:.*]] = call i32 @llvm.x86.avx512.ktestc.q
734 // OGCG: trunc i32 %[[RES]] to i8
735 return _ktestc_mask64_u8(A, B);
736 }
737
738 unsigned char test_ktestz_mask64_u8(__mmask64 A, __mmask64 B) {
739 // CIR-LABEL: _ktestz_mask64_u8
740 // CIR: %[[LHS:.*]] = cir.cast bitcast {{.*}} : !u64i -> !cir.vector<64 x !cir.int<s, 1>>
741 // CIR: %[[RHS:.*]] = cir.cast bitcast {{.*}} : !u64i -> !cir.vector<64 x !cir.int<s, 1>>
742 // CIR: %[[RES:.*]] = cir.call_llvm_intrinsic "x86.avx512.ktestz.q"
743 // CIR: cir.cast integral %[[RES]] : {{.*}} -> !u8i
744
745 // LLVM-LABEL: _ktestz_mask64_u8
746 // LLVM: %[[LHS:.*]] = bitcast i64 %{{.*}} to <64 x i1>
747 // LLVM: %[[RHS:.*]] = bitcast i64 %{{.*}} to <64 x i1>
748 // LLVM: %[[RES:.*]] = call i32 @llvm.x86.avx512.ktestz.q(<64 x i1> %[[LHS]], <64 x i1> %[[RHS]])
749 // LLVM: trunc i32 %[[RES]] to i8
750
751 // OGCG-LABEL: _ktestz_mask64_u8
752 // OGCG: %[[LHS:.*]] = bitcast i64 %{{.*}} to <64 x i1>
753 // OGCG: %[[RHS:.*]] = bitcast i64 %{{.*}} to <64 x i1>
754 // OGCG: %[[RES:.*]] = call i32 @llvm.x86.avx512.ktestz.q
755 // OGCG: trunc i32 %[[RES]] to i8
756 return _ktestz_mask64_u8(A, B);
757 }
758
759 __m512i test_mm512_movm_epi16(__mmask32 __A) {
760 // CIR-LABEL: _mm512_movm_epi16
761 // CIR: %{{.*}} = cir.cast bitcast %{{.*}} : !u32i -> !cir.vector<32 x !cir.int<s, 1>>
762 // CIR: %{{.*}} = cir.cast integral %{{.*}} : !cir.vector<32 x !cir.int<s, 1>> -> !cir.vector<32 x !s16i>
763
764 // LLVM-LABEL: test_mm512_movm_epi16
765 // LLVM: %{{.*}} = bitcast i32 %{{.*}} to <32 x i1>
766 // LLVM: %{{.*}} = sext <32 x i1> %{{.*}} to <32 x i16>
767
768 // OGCG-LABEL: {{.*}}movm_epi16{{.*}}(
769 // OGCG: %{{.*}} = bitcast i32 %{{.*}} to <32 x i1>
770 // OGCG: %{{.*}} = sext <32 x i1> %{{.*}} to <32 x i16>
771 return _mm512_movm_epi16(__A);
772 }
773
774 __mmask64 test_mm512_movepi8_mask(__m512i __A) {
775 // CIR-LABEL: _mm512_movepi8_mask
776 // CIR: cir.cast bitcast %{{.*}} : !cir.vector<8 x !s64i> -> !cir.vector<64 x !s8i>
777 // CIR: [[CMP:%.*]] = cir.vec.cmp(lt, %{{.*}}, %{{.*}}) : !cir.vector<64 x !s8i>, !cir.vector<64 x !cir.int<s, 1>>
778 // CIR: %{{.*}} = cir.cast bitcast [[CMP]] : !cir.vector<64 x !cir.int<s, 1>> -> !u64i
779
780 // LLVM-LABEL: test_mm512_movepi8_mask
781 // LLVM: [[CMP:%.*]] = icmp slt <64 x i8> %{{.*}}, zeroinitializer
782 // LLVM: bitcast <64 x i1> [[CMP]] to i64
783
784 // OGCG-LABEL: {{.*}}movepi8_mask{{.*}}(
785 // OGCG: [[CMP:%.*]] = icmp slt <64 x i8> %{{.*}}, zeroinitializer
786 // OGCG: bitcast <64 x i1> [[CMP]] to i64
787 return _mm512_movepi8_mask(__A);
788 }
789
790 __mmask32 test_mm512_movepi16_mask(__m512i __A) {
791 // CIR-LABEL: _mm512_movepi16_mask
792 // CIR: cir.cast bitcast %{{.*}} : !cir.vector<8 x !s64i> -> !cir.vector<32 x !s16i>
793 // CIR: [[CMP:%.*]] = cir.vec.cmp(lt, %{{.*}}, %{{.*}}) : !cir.vector<32 x !s16i>, !cir.vector<32 x !cir.int<s, 1>>
794 // CIR: %{{.*}} = cir.cast bitcast [[CMP]] : !cir.vector<32 x !cir.int<s, 1>> -> !u32i
795
796 // LLVM-LABEL: test_mm512_movepi16_mask
797 // LLVM: [[CMP:%.*]] = icmp slt <32 x i16> %{{.*}}, zeroinitializer
798 // LLVM: bitcast <32 x i1> [[CMP]] to i32
799
800 // OGCG-LABEL: {{.*}}movepi16_mask{{.*}}(
801 // OGCG: [[CMP:%.*]] = icmp slt <32 x i16> %{{.*}}, zeroinitializer
802 // OGCG: bitcast <32 x i1> [[CMP]] to i32
803 return _mm512_movepi16_mask(__A);
804 }
805
806 __m256i test_mm512_cvtepi16_epi8(__m512i __A) {
807 // CIR-LABEL: test_mm512_cvtepi16_epi8
808 // CIR: %[[TRUNC:.*]] = cir.cast integral {{.*}} : !cir.vector<32 x !s16i> -> !cir.vector<32 x !s8i>
809 // CIR: %[[RETBC:.*]] = cir.cast bitcast {{.*}} : !cir.vector<32 x !s8i> -> !cir.vector<4 x !s64i>
810 // CIR: cir.store %[[RETBC]], %[[RETPTR:.*]] : !cir.vector<4 x !s64i>, !cir.ptr<!cir.vector<4 x !s64i>>
811 // CIR: %[[RETLOAD:.*]] = cir.load %[[RETPTR]] : !cir.ptr<!cir.vector<4 x !s64i>>, !cir.vector<4 x !s64i>
812 // CIR: cir.return %[[RETLOAD]] : !cir.vector<4 x !s64i>
813
814 // LLVM-LABEL: test_mm512_cvtepi16_epi8
815 // LLVM: %[[TRUNC:.*]] = trunc <32 x i16> %{{.*}} to <32 x i8>
816 // LLVM: bitcast <32 x i8> %[[TRUNC]] to <4 x i64>
817
818 // OGCG-LABEL: test_mm512_cvtepi16_epi8
819 // OGCG: %[[TRUNC:.*]] = trunc <32 x i16> %{{.*}} to <32 x i8>
820 // OGCG: bitcast <32 x i8> %[[TRUNC]] to <4 x i64>
821 return _mm512_cvtepi16_epi8(__A);
822 }
823
824 __m256i test_mm512_mask_cvtepi16_epi8(__m256i __O, __mmask32 __M, __m512i __A) {
825 // CIR-LABEL: test_mm512_mask_cvtepi16_epi8
826 // CIR: %[[TRUNC:.*]] = cir.cast integral {{.*}} : !cir.vector<32 x !s16i> -> !cir.vector<32 x !s8i>
827 // CIR: %[[MASK_VEC:.*]] = cir.cast bitcast {{.*}} : !u32i -> !cir.vector<32 x !cir.int<s, 1>>
828 // CIR: %[[TER:.*]] = cir.vec.ternary(%[[MASK_VEC]], %[[TRUNC]], {{.*}}) : !cir.vector<32 x !cir.int<s, 1>>, !cir.vector<32 x !s8i>
829 // CIR: %[[RETBC:.*]] = cir.cast bitcast %[[TER]] : !cir.vector<32 x !s8i> -> !cir.vector<4 x !s64i>
830 // CIR: cir.store %[[RETBC]], %[[RETPTR:.*]] : !cir.vector<4 x !s64i>, !cir.ptr<!cir.vector<4 x !s64i>>
831 // CIR: %[[RETLOAD:.*]] = cir.load %[[RETPTR]] : !cir.ptr<!cir.vector<4 x !s64i>>, !cir.vector<4 x !s64i>
832 // CIR: cir.return %[[RETLOAD]] : !cir.vector<4 x !s64i>
833
834 // LLVM-LABEL: test_mm512_mask_cvtepi16_epi8
835 // LLVM: %[[TRUNC:.*]] = trunc <32 x i16> %{{.*}} to <32 x i8>
836 // LLVM: %[[MASK_VEC:.*]] = bitcast i32 %{{.*}} to <32 x i1>
837 // LLVM: %[[SEL:.*]] = select <32 x i1> %[[MASK_VEC]], <32 x i8> %[[TRUNC]], <32 x i8> %{{.*}}
838 // LLVM: bitcast <32 x i8> %[[SEL]] to <4 x i64>
839
840 // OGCG-LABEL: test_mm512_mask_cvtepi16_epi8
841 // OGCG: %[[TRUNC:.*]] = trunc <32 x i16> %{{.*}} to <32 x i8>
842 // OGCG: %[[MASK_VEC:.*]] = bitcast i32 %{{.*}} to <32 x i1>
843 // OGCG: %[[SEL:.*]] = select <32 x i1> %[[MASK_VEC]], <32 x i8> %[[TRUNC]], <32 x i8> %{{.*}}
844 // OGCG: bitcast <32 x i8> %[[SEL]] to <4 x i64>
845 return _mm512_mask_cvtepi16_epi8(__O, __M, __A);
846 }
847
848 __m256i test_mm512_maskz_cvtepi16_epi8(__mmask32 __M, __m512i __A) {
849 // CIR-LABEL: test_mm512_maskz_cvtepi16_epi8
850 // CIR: %[[CALL:.*]] = cir.call {{.*}} : (!u32i, !cir.vector<8 x !s64i>) -> !cir.vector<4 x !s64i>
851 // CIR: cir.store %[[CALL]], %[[RETPTR:.*]] : !cir.vector<4 x !s64i>, !cir.ptr<!cir.vector<4 x !s64i>>
852 // CIR: %[[RETLOAD:.*]] = cir.load %[[RETPTR]] : !cir.ptr<!cir.vector<4 x !s64i>>, !cir.vector<4 x !s64i>
853 // CIR: cir.return %[[RETLOAD]] : !cir.vector<4 x !s64i>
854
855 // LLVM-LABEL: test_mm512_maskz_cvtepi16_epi8
856 // LLVM: %[[TRUNC:.*]] = trunc <32 x i16> %{{.*}} to <32 x i8>
857 // LLVM: %[[MASK_VEC:.*]] = bitcast i32 %{{.*}} to <32 x i1>
858 // LLVM: %[[SEL:.*]] = select <32 x i1> %[[MASK_VEC]], <32 x i8> %[[TRUNC]], <32 x i8> {{.*}}
859 // LLVM: bitcast <32 x i8> %[[SEL]] to <4 x i64>
860
861 // OGCG-LABEL: test_mm512_maskz_cvtepi16_epi8
862 // OGCG: %[[TRUNC:.*]] = trunc <32 x i16> %{{.*}} to <32 x i8>
863 // OGCG: %[[MASK_VEC:.*]] = bitcast i32 %{{.*}} to <32 x i1>
864 // OGCG: %[[SEL:.*]] = select <32 x i1> %[[MASK_VEC]], <32 x i8> %[[TRUNC]], <32 x i8> {{.*}}
865 // OGCG: bitcast <32 x i8> %[[SEL]] to <4 x i64>
866 return _mm512_maskz_cvtepi16_epi8(__M, __A);
867 }
868
869 __m512i test_mm512_alignr_epi8(__m512i __A,__m512i __B) {
870 // CIR-LABEL: _mm512_alignr_epi8
871 // CIR: %{{.*}} = cir.vec.shuffle(%{{.*}}, %{{.*}} : !cir.vector<64 x {{!s8i|!u8i}}>) [#cir.int<2> : !s32i, #cir.int<3> : !s32i, #cir.int<4> : !s32i, #cir.int<5> : !s32i, #cir.int<6> : !s32i, #cir.int<7> : !s32i, #cir.int<8> : !s32i, #cir.int<9> : !s32i, #cir.int<10> : !s32i, #cir.int<11> : !s32i, #cir.int<12> : !s32i, #cir.int<13> : !s32i, #cir.int<14> : !s32i, #cir.int<15> : !s32i, #cir.int<64> : !s32i, #cir.int<65> : !s32i, #cir.int<18> : !s32i, #cir.int<19> : !s32i, #cir.int<20> : !s32i, #cir.int<21> : !s32i, #cir.int<22> : !s32i, #cir.int<23> : !s32i, #cir.int<24> : !s32i, #cir.int<25> : !s32i, #cir.int<26> : !s32i, #cir.int<27> : !s32i, #cir.int<28> : !s32i, #cir.int<29> : !s32i, #cir.int<30> : !s32i, #cir.int<31> : !s32i, #cir.int<80> : !s32i, #cir.int<81> : !s32i, #cir.int<34> : !s32i, #cir.int<35> : !s32i, #cir.int<36> : !s32i, #cir.int<37> : !s32i, #cir.int<38> : !s32i, #cir.int<39> : !s32i, #cir.int<40> : !s32i, #cir.int<41> : !s32i, #cir.int<42> : !s32i, #cir.int<43> : !s32i, #cir.int<44> : !s32i, #cir.int<45> : !s32i, #cir.int<46> : !s32i, #cir.int<47> : !s32i, #cir.int<96> : !s32i, #cir.int<97> : !s32i, #cir.int<50> : !s32i, #cir.int<51> : !s32i, #cir.int<52> : !s32i, #cir.int<53> : !s32i, #cir.int<54> : !s32i, #cir.int<55> : !s32i, #cir.int<56> : !s32i, #cir.int<57> : !s32i, #cir.int<58> : !s32i, #cir.int<59> : !s32i, #cir.int<60> : !s32i, #cir.int<61> : !s32i, #cir.int<62> : !s32i, #cir.int<63> : !s32i, #cir.int<112> : !s32i, #cir.int<113> : !s32i] : !cir.vector<64 x {{!s8i|!u8i}}>
872
873 // LLVM-LABEL: test_mm512_alignr_epi8
874 // LLVM: shufflevector <64 x i8> %{{.*}}, <64 x i8> %{{.*}}, <64 x i32> <i32 2, i32 3, i32 4, i32 5, i32 6, i32 7, i32 8, i32 9, i32 10, i32 11, i32 12, i32 13, i32 14, i32 15, i32 64, i32 65, i32 18, i32 19, i32 20, i32 21, i32 22, i32 23, i32 24, i32 25, i32 26, i32 27, i32 28, i32 29, i32 30, i32 31, i32 80, i32 81, i32 34, i32 35, i32 36, i32 37, i32 38, i32 39, i32 40, i32 41, i32 42, i32 43, i32 44, i32 45, i32 46, i32 47, i32 96, i32 97, i32 50, i32 51, i32 52, i32 53, i32 54, i32 55, i32 56, i32 57, i32 58, i32 59, i32 60, i32 61, i32 62, i32 63, i32 112, i32 113>
875
876 // OGCG-LABEL: test_mm512_alignr_epi8
877 // OGCG: shufflevector <64 x i8> %{{.*}}, <64 x i8> %{{.*}}, <64 x i32> <i32 2, i32 3, i32 4, i32 5, i32 6, i32 7, i32 8, i32 9, i32 10, i32 11, i32 12, i32 13, i32 14, i32 15, i32 64, i32 65, i32 18, i32 19, i32 20, i32 21, i32 22, i32 23, i32 24, i32 25, i32 26, i32 27, i32 28, i32 29, i32 30, i32 31, i32 80, i32 81, i32 34, i32 35, i32 36, i32 37, i32 38, i32 39, i32 40, i32 41, i32 42, i32 43, i32 44, i32 45, i32 46, i32 47, i32 96, i32 97, i32 50, i32 51, i32 52, i32 53, i32 54, i32 55, i32 56, i32 57, i32 58, i32 59, i32 60, i32 61, i32 62, i32 63, i32 112, i32 113>
878 return _mm512_alignr_epi8(__A, __B, 2);
879 }