1 ; RUN: llc < %s -march=x86-64 -mattr=+bmi,+bmi2 | FileCheck %s
3 declare i8 @llvm.cttz.i8(i8, i1) nounwind readnone
4 declare i16 @llvm.cttz.i16(i16, i1) nounwind readnone
5 declare i32 @llvm.cttz.i32(i32, i1) nounwind readnone
6 declare i64 @llvm.cttz.i64(i64, i1) nounwind readnone
8 define i8 @t1(i8 %x) nounwind {
9 %tmp = tail call i8 @llvm.cttz.i8( i8 %x, i1 false )
15 define i16 @t2(i16 %x) nounwind {
16 %tmp = tail call i16 @llvm.cttz.i16( i16 %x, i1 false )
22 define i32 @t3(i32 %x) nounwind {
23 %tmp = tail call i32 @llvm.cttz.i32( i32 %x, i1 false )
29 define i32 @tzcnt32_load(i32* %x) nounwind {
31 %tmp = tail call i32 @llvm.cttz.i32(i32 %x1, i1 false )
33 ; CHECK-LABEL: tzcnt32_load:
34 ; CHECK: tzcntl ({{.*}})
37 define i64 @t4(i64 %x) nounwind {
38 %tmp = tail call i64 @llvm.cttz.i64( i64 %x, i1 false )
44 define i8 @t5(i8 %x) nounwind {
45 %tmp = tail call i8 @llvm.cttz.i8( i8 %x, i1 true )
51 define i16 @t6(i16 %x) nounwind {
52 %tmp = tail call i16 @llvm.cttz.i16( i16 %x, i1 true )
58 define i32 @t7(i32 %x) nounwind {
59 %tmp = tail call i32 @llvm.cttz.i32( i32 %x, i1 true )
65 define i64 @t8(i64 %x) nounwind {
66 %tmp = tail call i64 @llvm.cttz.i64( i64 %x, i1 true )
72 define i32 @andn32(i32 %x, i32 %y) nounwind readnone {
73 %tmp1 = xor i32 %x, -1
74 %tmp2 = and i32 %y, %tmp1
76 ; CHECK-LABEL: andn32:
80 define i32 @andn32_load(i32 %x, i32* %y) nounwind readnone {
82 %tmp1 = xor i32 %x, -1
83 %tmp2 = and i32 %y1, %tmp1
85 ; CHECK-LABEL: andn32_load:
86 ; CHECK: andnl ({{.*}})
89 define i64 @andn64(i64 %x, i64 %y) nounwind readnone {
90 %tmp1 = xor i64 %x, -1
91 %tmp2 = and i64 %tmp1, %y
93 ; CHECK-LABEL: andn64:
97 define i32 @bextr32(i32 %x, i32 %y) nounwind readnone {
98 %tmp = tail call i32 @llvm.x86.bmi.bextr.32(i32 %x, i32 %y)
100 ; CHECK-LABEL: bextr32:
104 define i32 @bextr32_load(i32* %x, i32 %y) nounwind readnone {
106 %tmp = tail call i32 @llvm.x86.bmi.bextr.32(i32 %x1, i32 %y)
108 ; CHECK-LABEL: bextr32_load:
109 ; CHECK: bextrl {{.*}}, ({{.*}}), {{.*}}
112 declare i32 @llvm.x86.bmi.bextr.32(i32, i32) nounwind readnone
114 define i32 @bextr32b(i32 %x) nounwind uwtable readnone ssp {
116 %2 = and i32 %1, 4095
118 ; CHECK-LABEL: bextr32b:
122 define i32 @bextr32b_load(i32* %x) nounwind uwtable readnone ssp {
125 %3 = and i32 %2, 4095
127 ; CHECK-LABEL: bextr32b_load:
128 ; CHECK: bextrl {{.*}}, ({{.*}}), {{.*}}
131 define i64 @bextr64(i64 %x, i64 %y) nounwind readnone {
132 %tmp = tail call i64 @llvm.x86.bmi.bextr.64(i64 %x, i64 %y)
134 ; CHECK-LABEL: bextr64:
138 declare i64 @llvm.x86.bmi.bextr.64(i64, i64) nounwind readnone
140 define i64 @bextr64b(i64 %x) nounwind uwtable readnone ssp {
142 %2 = and i64 %1, 4095
144 ; CHECK-LABEL: bextr64b:
148 define i32 @bzhi32(i32 %x, i32 %y) nounwind readnone {
149 %tmp = tail call i32 @llvm.x86.bmi.bzhi.32(i32 %x, i32 %y)
151 ; CHECK-LABEL: bzhi32:
155 define i32 @bzhi32_load(i32* %x, i32 %y) nounwind readnone {
157 %tmp = tail call i32 @llvm.x86.bmi.bzhi.32(i32 %x1, i32 %y)
159 ; CHECK-LABEL: bzhi32_load:
160 ; CHECK: bzhil {{.*}}, ({{.*}}), {{.*}}
163 declare i32 @llvm.x86.bmi.bzhi.32(i32, i32) nounwind readnone
165 define i64 @bzhi64(i64 %x, i64 %y) nounwind readnone {
166 %tmp = tail call i64 @llvm.x86.bmi.bzhi.64(i64 %x, i64 %y)
168 ; CHECK-LABEL: bzhi64:
172 declare i64 @llvm.x86.bmi.bzhi.64(i64, i64) nounwind readnone
174 define i32 @bzhi32b(i32 %x, i8 zeroext %index) #0 {
176 %conv = zext i8 %index to i32
177 %shl = shl i32 1, %conv
178 %sub = add nsw i32 %shl, -1
179 %and = and i32 %sub, %x
181 ; CHECK-LABEL: bzhi32b:
185 define i32 @bzhi32b_load(i32* %w, i8 zeroext %index) #0 {
188 %conv = zext i8 %index to i32
189 %shl = shl i32 1, %conv
190 %sub = add nsw i32 %shl, -1
191 %and = and i32 %sub, %x
193 ; CHECK-LABEL: bzhi32b_load:
194 ; CHECK: bzhil {{.*}}, ({{.*}}), {{.*}}
197 define i32 @bzhi32c(i32 %x, i8 zeroext %index) #0 {
199 %conv = zext i8 %index to i32
200 %shl = shl i32 1, %conv
201 %sub = add nsw i32 %shl, -1
202 %and = and i32 %x, %sub
204 ; CHECK-LABEL: bzhi32c:
208 define i64 @bzhi64b(i64 %x, i8 zeroext %index) #0 {
210 %conv = zext i8 %index to i64
211 %shl = shl i64 1, %conv
212 %sub = add nsw i64 %shl, -1
213 %and = and i64 %x, %sub
215 ; CHECK-LABEL: bzhi64b:
219 define i32 @bzhi32_constant_mask(i32 %x) #0 {
221 %and = and i32 %x, 1073741823
223 ; CHECK-LABEL: bzhi32_constant_mask:
224 ; CHECK: movb $30, %al
225 ; CHECK: bzhil %eax, %edi, %eax
228 define i64 @bzhi64_constant_mask(i64 %x) #0 {
230 %and = and i64 %x, 4611686018427387903
232 ; CHECK-LABEL: bzhi64_constant_mask:
233 ; CHECK: movb $62, %al
234 ; CHECK: bzhiq %rax, %rdi, %rax
237 define i32 @blsi32(i32 %x) nounwind readnone {
239 %tmp2 = and i32 %x, %tmp
241 ; CHECK-LABEL: blsi32:
245 define i32 @blsi32_load(i32* %x) nounwind readnone {
247 %tmp = sub i32 0, %x1
248 %tmp2 = and i32 %x1, %tmp
250 ; CHECK-LABEL: blsi32_load:
251 ; CHECK: blsil ({{.*}})
254 define i64 @blsi64(i64 %x) nounwind readnone {
256 %tmp2 = and i64 %tmp, %x
258 ; CHECK-LABEL: blsi64:
262 define i32 @blsmsk32(i32 %x) nounwind readnone {
264 %tmp2 = xor i32 %x, %tmp
266 ; CHECK-LABEL: blsmsk32:
270 define i32 @blsmsk32_load(i32* %x) nounwind readnone {
272 %tmp = sub i32 %x1, 1
273 %tmp2 = xor i32 %x1, %tmp
275 ; CHECK-LABEL: blsmsk32_load:
276 ; CHECK: blsmskl ({{.*}})
279 define i64 @blsmsk64(i64 %x) nounwind readnone {
281 %tmp2 = xor i64 %tmp, %x
283 ; CHECK-LABEL: blsmsk64:
287 define i32 @blsr32(i32 %x) nounwind readnone {
289 %tmp2 = and i32 %x, %tmp
291 ; CHECK-LABEL: blsr32:
295 define i32 @blsr32_load(i32* %x) nounwind readnone {
297 %tmp = sub i32 %x1, 1
298 %tmp2 = and i32 %x1, %tmp
300 ; CHECK-LABEL: blsr32_load:
301 ; CHECK: blsrl ({{.*}})
304 define i64 @blsr64(i64 %x) nounwind readnone {
306 %tmp2 = and i64 %tmp, %x
308 ; CHECK-LABEL: blsr64:
312 define i32 @pdep32(i32 %x, i32 %y) nounwind readnone {
313 %tmp = tail call i32 @llvm.x86.bmi.pdep.32(i32 %x, i32 %y)
315 ; CHECK-LABEL: pdep32:
319 define i32 @pdep32_load(i32 %x, i32* %y) nounwind readnone {
321 %tmp = tail call i32 @llvm.x86.bmi.pdep.32(i32 %x, i32 %y1)
323 ; CHECK-LABEL: pdep32_load:
324 ; CHECK: pdepl ({{.*}})
327 declare i32 @llvm.x86.bmi.pdep.32(i32, i32) nounwind readnone
329 define i64 @pdep64(i64 %x, i64 %y) nounwind readnone {
330 %tmp = tail call i64 @llvm.x86.bmi.pdep.64(i64 %x, i64 %y)
332 ; CHECK-LABEL: pdep64:
336 declare i64 @llvm.x86.bmi.pdep.64(i64, i64) nounwind readnone
338 define i32 @pext32(i32 %x, i32 %y) nounwind readnone {
339 %tmp = tail call i32 @llvm.x86.bmi.pext.32(i32 %x, i32 %y)
341 ; CHECK-LABEL: pext32:
345 define i32 @pext32_load(i32 %x, i32* %y) nounwind readnone {
347 %tmp = tail call i32 @llvm.x86.bmi.pext.32(i32 %x, i32 %y1)
349 ; CHECK-LABEL: pext32_load:
350 ; CHECK: pextl ({{.*}})
353 declare i32 @llvm.x86.bmi.pext.32(i32, i32) nounwind readnone
355 define i64 @pext64(i64 %x, i64 %y) nounwind readnone {
356 %tmp = tail call i64 @llvm.x86.bmi.pext.64(i64 %x, i64 %y)
358 ; CHECK-LABEL: pext64:
362 declare i64 @llvm.x86.bmi.pext.64(i64, i64) nounwind readnone