Debian Codegraph @

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

raw
1 // RUN: %clang_cc1 -flax-vector-conversions=none -ffreestanding %s -triple=x86_64-unknown-linux -target-feature +avx512dq -target-feature +avx512vl -fclangir -emit-cir -o %t.cir -Wall -Werror
2 // RUN: FileCheck --check-prefix=CIR --input-file=%t.cir %s
3 // RUN: %clang_cc1 -flax-vector-conversions=none -ffreestanding %s -triple=x86_64-unknown-linux -target-feature +avx512dq -target-feature +avx512vl -fclangir -emit-llvm -o %t.ll -Wall -Werror
4 // RUN: FileCheck --check-prefixes=LLVM --input-file=%t.ll %s
5 // RUN: %clang_cc1 -flax-vector-conversions=none -ffreestanding %s -triple=x86_64-apple-darwin -target-feature +avx512dq -target-feature +avx512vl -emit-llvm -o - -Wall -Werror | FileCheck %s --check-prefixes=OGCG
6
7 #include <immintrin.h>
8
9
10 __m128i test_mm_movm_epi32(__mmask8 __A) {
11 // CIR-LABEL: _mm_movm_epi32
12 // CIR: %{{.*}} = cir.cast bitcast %{{.*}} : !u8i -> !cir.vector<8 x !cir.int<s, 1>>
13 // CIR: %{{.*}} = cir.vec.shuffle(%{{.*}}, %{{.*}} : !cir.vector<8 x !cir.int<s, 1>>) [#cir.int<0> : !s32i, #cir.int<1> : !s32i, #cir.int<2> : !s32i, #cir.int<3> : !s32i] : !cir.vector<4 x !cir.int<s, 1>>
14 // CIR: %{{.*}} = cir.cast integral %{{.*}} : !cir.vector<4 x !cir.int<s, 1>> -> !cir.vector<4 x !s32i>
15
16 // LLVM-LABEL: @test_mm_movm_epi32
17 // LLVM: %{{.*}} = bitcast i8 %{{.*}} to <8 x i1>
18 // LLVM: %{{.*}} = shufflevector <8 x i1> %{{.*}}, <8 x i1> %{{.*}}, <4 x i32> <i32 0, i32 1, i32 2, i32 3>
19 // LLVM: %{{.*}} = sext <4 x i1> %{{.*}} to <4 x i32>
20
21 // OGCG-LABEL: @test_mm_movm_epi32
22 // OGCG: %{{.*}} = bitcast i8 %{{.*}} to <8 x i1>
23 // OGCG: %{{.*}} = shufflevector <8 x i1> %{{.*}}, <8 x i1> %{{.*}}, <4 x i32> <i32 0, i32 1, i32 2, i32 3>
24 // OGCG: %{{.*}} = sext <4 x i1> %{{.*}} to <4 x i32>
25 return _mm_movm_epi32(__A);
26 }
27
28 __m256i test_mm256_movm_epi32(__mmask8 __A) {
29 // CIR-LABEL: _mm256_movm_epi32
30 // CIR: %{{.*}} = cir.cast bitcast %{{.*}} : !u8i -> !cir.vector<8 x !cir.int<s, 1>>
31 // CIR: %{{.*}} = cir.cast integral %{{.*}} : !cir.vector<8 x !cir.int<s, 1>> -> !cir.vector<8 x !s32i>
32
33 // LLVM-LABEL: @test_mm256_movm_epi32
34 // LLVM: %{{.*}} = bitcast i8 %{{.*}} to <8 x i1>
35 // LLVM: %{{.*}} = sext <8 x i1> %{{.*}} to <8 x i32>
36
37 // OGCG-LABEL: @test_mm256_movm_epi32
38 // OGCG: %{{.*}} = bitcast i8 %{{.*}} to <8 x i1>
39 // OGCG: %{{.*}} = sext <8 x i1> %{{.*}} to <8 x i32>
40 return _mm256_movm_epi32(__A);
41 }
42
43 __m512i test_mm512_movm_epi32(__mmask16 __A) {
44 // CIR-LABEL: _mm512_movm_epi32
45 // CIR: %{{.*}} = cir.cast bitcast %{{.*}} : !u16i -> !cir.vector<16 x !cir.int<s, 1>>
46 // CIR: %{{.*}} = cir.cast integral %{{.*}} : !cir.vector<16 x !cir.int<s, 1>> -> !cir.vector<16 x !s32i>
47
48 // LLVM-LABEL: @test_mm512_movm_epi32
49 // LLVM: %{{.*}} = bitcast i16 %{{.*}} to <16 x i1>
50 // LLVM: %{{.*}} = sext <16 x i1> %{{.*}} to <16 x i32>
51
52 // OGCG-LABEL: @test_mm512_movm_epi32
53 // OGCG: %{{.*}} = bitcast i16 %{{.*}} to <16 x i1>
54 // OGCG: %{{.*}} = sext <16 x i1> %{{.*}} to <16 x i32>
55 return _mm512_movm_epi32(__A);
56 }
57
58 __m128i test_mm_movm_epi64(__mmask8 __A) {
59 // CIR-LABEL: _mm_movm_epi64
60 // CIR: %{{.*}} = cir.cast bitcast %{{.*}} : !u8i -> !cir.vector<8 x !cir.int<s, 1>>
61 // CIR: %{{.*}} = cir.vec.shuffle(%{{.*}}, %{{.*}} : !cir.vector<8 x !cir.int<s, 1>>) [#cir.int<0> : !s32i, #cir.int<1> : !s32i] : !cir.vector<2 x !cir.int<s, 1>>
62 // CIR: %{{.*}} = cir.cast integral %{{.*}} : !cir.vector<2 x !cir.int<s, 1>> -> !cir.vector<2 x !s64i>
63
64 // LLVM-LABEL: @test_mm_movm_epi64
65 // LLVM: %{{.*}} = bitcast i8 %{{.*}} to <8 x i1>
66 // LLVM: %{{.*}} = shufflevector <8 x i1> %{{.*}}, <8 x i1> %{{.*}}, <2 x i32> <i32 0, i32 1>
67 // LLVM: %{{.*}} = sext <2 x i1> %{{.*}} to <2 x i64>
68
69 // OGCG-LABEL: @test_mm_movm_epi64
70 // OGCG: %{{.*}} = bitcast i8 %{{.*}} to <8 x i1>
71 // OGCG: %{{.*}} = shufflevector <8 x i1> %{{.*}}, <8 x i1> %{{.*}}, <2 x i32> <i32 0, i32 1>
72 // OGCG: %{{.*}} = sext <2 x i1> %{{.*}} to <2 x i64>
73 return _mm_movm_epi64(__A);
74 }
75
76 __m256i test_mm256_movm_epi64(__mmask8 __A) {
77 // CIR-LABEL: _mm256_movm_epi64
78 // CIR: %{{.*}} = cir.cast bitcast %{{.*}} : !u8i -> !cir.vector<8 x !cir.int<s, 1>>
79 // CIR: %{{.*}} = cir.vec.shuffle(%{{.*}}, %{{.*}} : !cir.vector<8 x !cir.int<s, 1>>) [#cir.int<0> : !s32i, #cir.int<1> : !s32i, #cir.int<2> : !s32i, #cir.int<3> : !s32i] : !cir.vector<4 x !cir.int<s, 1>>
80 // CIR: %{{.*}} = cir.cast integral %{{.*}} : !cir.vector<4 x !cir.int<s, 1>> -> !cir.vector<4 x !s64i>
81
82 // LLVM-LABEL: @test_mm256_movm_epi64
83 // LLVM: %{{.*}} = bitcast i8 %{{.*}} to <8 x i1>
84 // LLVM: %{{.*}} = shufflevector <8 x i1> %{{.*}}, <8 x i1> %{{.*}}, <4 x i32> <i32 0, i32 1, i32 2, i32 3>
85 // LLVM: %{{.*}} = sext <4 x i1> %{{.*}} to <4 x i64>
86
87 // OGCG-LABEL: @test_mm256_movm_epi64
88 // OGCG: %{{.*}} = bitcast i8 %{{.*}} to <8 x i1>
89 // OGCG: %{{.*}} = shufflevector <8 x i1> %{{.*}}, <8 x i1> %{{.*}}, <4 x i32> <i32 0, i32 1, i32 2, i32 3>
90 // OGCG: %{{.*}} = sext <4 x i1> %{{.*}} to <4 x i64>
91 return _mm256_movm_epi64(__A);
92 }
93
94 __mmask8 test_mm256_movepi32_mask(__m256i __A) {
95 // CIR-LABEL: _mm256_movepi32_mask
96 // CIR: [[CMP:%.*]] = cir.vec.cmp(lt, %{{.*}}, %{{.*}}) : !cir.vector<8 x !s32i>, !cir.vector<8 x !cir.int<s, 1>>
97 // CIR: %{{.*}} = cir.cast bitcast [[CMP]] : !cir.vector<8 x !cir.int<s, 1>> -> !u8i
98
99 // LLVM-LABEL: @test_mm256_movepi32_mask
100 // LLVM: [[CMP:%.*]] = icmp slt <8 x i32> %{{.*}}, zeroinitializer
101 // LLVM: bitcast <8 x i1> [[CMP]] to i8
102
103 // OGCG-LABEL: @test_mm256_movepi32_mask
104 // OGCG: [[CMP:%.*]] = icmp slt <8 x i32> %{{.*}}, zeroinitializer
105 // OGCG: bitcast <8 x i1> [[CMP]] to i8
106 return _mm256_movepi32_mask(__A);
107 }
108
109 __mmask8 test_mm_movepi64_mask(__m128i __A) {
110 // CIR-LABEL: _mm_movepi64_mask
111 // CIR: %{{.*}} = cir.vec.cmp(lt, %{{.*}}, %{{.*}}) : !cir.vector<2 x !s64i>, !cir.vector<2 x !cir.int<s, 1>>
112 // CIR: %{{.*}} = cir.vec.shuffle(%{{.*}}, %{{.*}} : !cir.vector<2 x !cir.int<s, 1>>) [#cir.int<0> : !s64i, #cir.int<1> : !s64i, #cir.int<2> : !s64i, #cir.int<3> : !s64i, #cir.int<2> : !s64i, #cir.int<3> : !s64i, #cir.int<2> : !s64i, #cir.int<3> : !s64i] : !cir.vector<8 x !cir.int<s, 1>>
113 // CIR: %{{.*}} = cir.cast bitcast %{{.*}} : !cir.vector<8 x !cir.int<s, 1>> -> !u8i
114
115 // LLVM-LABEL: @test_mm_movepi64_mask
116 // LLVM: [[CMP:%.*]] = icmp slt <2 x i64> %{{.*}}, zeroinitializer
117 // LLVM: [[SHUF:%.*]] = shufflevector <2 x i1> [[CMP]], <2 x i1> zeroinitializer, <8 x i32> <i32 0, i32 1, i32 2, i32 3, i32 2, i32 3, i32 2, i32 3>
118 // LLVM: bitcast <8 x i1> [[SHUF]] to i8
119
120 // OGCG-LABEL: @test_mm_movepi64_mask
121 // OGCG: [[CMP:%.*]] = icmp slt <2 x i64> %{{.*}}, zeroinitializer
122 // OGCG: [[SHUF:%.*]] = shufflevector <2 x i1> [[CMP]], <2 x i1> zeroinitializer, <8 x i32> <i32 0, i32 1, i32 2, i32 3, i32 2, i32 3, i32 2, i32 3>
123 // OGCG: bitcast <8 x i1> [[SHUF]] to i8
124 return _mm_movepi64_mask(__A);
125 }
126
127 __mmask8 test_mm256_movepi64_mask(__m256i __A) {
128 // CIR-LABEL: _mm256_movepi64_mask
129 // CIR: [[CMP:%.*]] = cir.vec.cmp(lt, %{{.*}}, %{{.*}}) : !cir.vector<4 x !s64i>, !cir.vector<4 x !cir.int<s, 1>>
130 // CIR: [[SHUF:%.*]] = cir.vec.shuffle([[CMP]], %{{.*}} : !cir.vector<4 x !cir.int<s, 1>>) [#cir.int<0> : !s64i, #cir.int<1> : !s64i, #cir.int<2> : !s64i, #cir.int<3> : !s64i, #cir.int<4> : !s64i, #cir.int<5> : !s64i, #cir.int<6> : !s64i, #cir.int<7> : !s64i] : !cir.vector<8 x !cir.int<s, 1>>
131 // CIR: %{{.*}} = cir.cast bitcast [[SHUF]] : !cir.vector<8 x !cir.int<s, 1>> -> !u8i
132
133 // LLVM-LABEL: @test_mm256_movepi64_mask
134 // LLVM: [[CMP:%.*]] = icmp slt <4 x i64> %{{.*}}, zeroinitializer
135 // LLVM: [[SHUF:%.*]] = shufflevector <4 x i1> [[CMP]], <4 x i1> zeroinitializer, <8 x i32> <i32 0, i32 1, i32 2, i32 3, i32 4, i32 5, i32 6, i32 7>
136 // LLVM: bitcast <8 x i1> [[SHUF]] to i8
137
138 // OGCG-LABEL: @test_mm256_movepi64_mask
139 // OGCG: [[CMP:%.*]] = icmp slt <4 x i64> %{{.*}}, zeroinitializer
140 // OGCG: [[SHUF:%.*]] = shufflevector <4 x i1> [[CMP]], <4 x i1> zeroinitializer, <8 x i32> <i32 0, i32 1, i32 2, i32 3, i32 4, i32 5, i32 6, i32 7>
141 // OGCG: bitcast <8 x i1> [[SHUF]] to i8
142 return _mm256_movepi64_mask(__A);
143 }
144
145 __m256d test_mm256_insertf64x2(__m256d __A, __m128d __B) {
146 // CIR-LABEL: test_mm256_insertf64x2
147 // CIR: %{{.*}} = cir.vec.shuffle(%{{.*}}, %{{.*}} : !cir.vector<4 x !cir.double>) [#cir.int<0> : !s32i, #cir.int<1> : !s32i, #cir.int<4> : !s32i, #cir.int<5> : !s32i] : !cir.vector<4 x !cir.double>
148
149 // LLVM-LABEL: @test_mm256_insertf64x2
150 // LLVM: shufflevector <4 x double> %{{.*}}, <4 x double> %{{.*}}, <4 x i32> <i32 0, i32 1, i32 4, i32 5>
151
152 // OGCG-LABEL: @test_mm256_insertf64x2
153 // OGCG: shufflevector <4 x double> %{{.*}}, <4 x double> %{{.*}}, <4 x i32> <i32 0, i32 1, i32 4, i32 5>
154 return _mm256_insertf64x2(__A, __B, 1);
155 }
156
157 __m256i test_mm256_inserti64x2(__m256i __A, __m128i __B) {
158 // CIR-LABEL: test_mm256_inserti64x2
159 // CIR: %{{.*}} = cir.vec.shuffle(%{{.*}}, %{{.*}} : !cir.vector<4 x !s64i>) [#cir.int<0> : !s32i, #cir.int<1> : !s32i, #cir.int<4> : !s32i, #cir.int<5> : !s32i] : !cir.vector<4 x !s64i>
160
161 // LLVM-LABEL: @test_mm256_inserti64x2
162 // LLVM: shufflevector <4 x i64> %{{.*}}, <4 x i64> %{{.*}}, <4 x i32> <i32 0, i32 1, i32 4, i32 5>
163
164 // OGCG-LABEL: @test_mm256_inserti64x2
165 // OGCG: shufflevector <4 x i64> %{{.*}}, <4 x i64> %{{.*}}, <4 x i32> <i32 0, i32 1, i32 4, i32 5>
166 return _mm256_inserti64x2(__A, __B, 1);
167 }