@@ -297,8 +297,46 @@ define i64 @popz_i32_i64(i32 %x) {
297
297
ret i64 %z
298
298
}
299
299
300
+ define i64 @popa_i16_i64 (i16 %x ) {
301
+ ; FAST-LABEL: popa_i16_i64:
302
+ ; FAST: # %bb.0:
303
+ ; FAST-NEXT: rlwinm 3, 3, 0, 16, 31
304
+ ; FAST-NEXT: popcntw 3, 3
305
+ ; FAST-NEXT: andi. 3, 3, 16
306
+ ; FAST-NEXT: blr
307
+ ;
308
+ ; SLOW-LABEL: popa_i16_i64:
309
+ ; SLOW: # %bb.0:
310
+ ; SLOW-NEXT: clrlwi 5, 3, 16
311
+ ; SLOW-NEXT: rlwinm 3, 3, 31, 0, 31
312
+ ; SLOW-NEXT: andi. 3, 3, 21845
313
+ ; SLOW-NEXT: lis 4, 13107
314
+ ; SLOW-NEXT: subf 3, 3, 5
315
+ ; SLOW-NEXT: ori 4, 4, 13107
316
+ ; SLOW-NEXT: rotlwi 5, 3, 30
317
+ ; SLOW-NEXT: and 3, 3, 4
318
+ ; SLOW-NEXT: andis. 4, 5, 13107
319
+ ; SLOW-NEXT: andi. 5, 5, 13107
320
+ ; SLOW-NEXT: or 4, 5, 4
321
+ ; SLOW-NEXT: add 3, 3, 4
322
+ ; SLOW-NEXT: lis 5, 3855
323
+ ; SLOW-NEXT: srwi 4, 3, 4
324
+ ; SLOW-NEXT: add 3, 3, 4
325
+ ; SLOW-NEXT: lis 4, 257
326
+ ; SLOW-NEXT: ori 5, 5, 3855
327
+ ; SLOW-NEXT: and 3, 3, 5
328
+ ; SLOW-NEXT: ori 4, 4, 257
329
+ ; SLOW-NEXT: mullw 3, 3, 4
330
+ ; SLOW-NEXT: srwi 3, 3, 24
331
+ ; SLOW-NEXT: andi. 3, 3, 16
332
+ ; SLOW-NEXT: blr
333
+ %pop = call i16 @llvm.ctpop.i16 (i16 %x )
334
+ %z = zext i16 %pop to i64 ; SimplifyDemandedBits may turn zext (or sext) into aext
335
+ %a = and i64 %z , 16
336
+ ret i64 %a
337
+ }
338
+
300
339
declare i8 @llvm.ctpop.i8 (i8 ) nounwind readnone
301
340
declare i16 @llvm.ctpop.i16 (i16 ) nounwind readnone
302
341
declare i32 @llvm.ctpop.i32 (i32 ) nounwind readnone
303
342
declare i64 @llvm.ctpop.i64 (i64 ) nounwind readnone
304
-
0 commit comments