| 1 |
; RUN: llc -verify-machineinstrs -mtriple=ppc64-- -mattr=+popcntd < %s | FileCheck %s |
| 2 |
; RUN: llc -verify-machineinstrs -mtriple=ppc64-- -mattr=+slow-popcntd < %s | FileCheck %s --check-prefix=SLOWPC |
| 3 |
; RUN: llc -verify-machineinstrs -mtriple=ppc64-- -mcpu=pwr7 < %s | FileCheck %s |
| 4 |
|
| 5 |
define i64 @_cntb64(i64 %x) nounwind readnone { |
| 6 |
%cnt = tail call i64 @llvm.ppc.popcntb(i64 %x) |
| 7 |
ret i64 %cnt |
| 8 |
; CHECK-LABEL: @_cntb64 |
| 9 |
; CHECK: popcntb |
| 10 |
; CHECK: blr |
| 11 |
} |
| 12 |
|
| 13 |
define i32 @_cntb32(i32 %x) nounwind readnone { |
| 14 |
%y = zext i32 %x to i64 |
| 15 |
%cnt = tail call i64 @llvm.ppc.popcntb(i64 %y) |
| 16 |
%res = trunc i64 %cnt to i32 |
| 17 |
ret i32 %res |
| 18 |
; CHECK-LABEL: @_cntb32 |
| 19 |
; CHECK: popcntb |
| 20 |
; CHECK: blr |
| 21 |
} |
| 22 |
|
| 23 |
define i8 @cnt8(i8 %x) nounwind readnone { |
| 24 |
%cnt = tail call i8 @llvm.ctpop.i8(i8 %x) |
| 25 |
ret i8 %cnt |
| 26 |
; CHECK-LABEL: @cnt8 |
| 27 |
; CHECK: clrldi |
| 28 |
; CHECK: popcntd |
| 29 |
; CHECK: blr |
| 30 |
|
| 31 |
; SLOWPC-LABEL: @cnt8 |
| 32 |
; SLOWPC-NOT: popcnt |
| 33 |
} |
| 34 |
|
| 35 |
define i16 @cnt16(i16 %x) nounwind readnone { |
| 36 |
%cnt = tail call i16 @llvm.ctpop.i16(i16 %x) |
| 37 |
ret i16 %cnt |
| 38 |
; CHECK-LABEL: @cnt16 |
| 39 |
; CHECK: clrldi |
| 40 |
; CHECK: popcntd |
| 41 |
; CHECK: blr |
| 42 |
|
| 43 |
; SLOWPC-LABEL: @cnt16 |
| 44 |
; SLOWPC-NOT: popcnt |
| 45 |
} |
| 46 |
|
| 47 |
define i32 @cnt32(i32 %x) nounwind readnone { |
| 48 |
%cnt = tail call i32 @llvm.ctpop.i32(i32 %x) |
| 49 |
ret i32 %cnt |
| 50 |
; CHECK-LABEL: @cnt32 |
| 51 |
; CHECK: popcntw |
| 52 |
; CHECK: blr |
| 53 |
|
| 54 |
; SLOWPC-LABEL: @cnt32 |
| 55 |
; SLOWPC-NOT: popcnt |
| 56 |
} |
| 57 |
|
| 58 |
define i64 @cnt64(i64 %x) nounwind readnone { |
| 59 |
%cnt = tail call i64 @llvm.ctpop.i64(i64 %x) |
| 60 |
ret i64 %cnt |
| 61 |
; CHECK-LABEL: @cnt64 |
| 62 |
; CHECK: popcntd |
| 63 |
; CHECK: blr |
| 64 |
|
| 65 |
; SLOWPC-LABEL: @cnt64 |
| 66 |
; SLOWPC-NOT: popcnt |
| 67 |
} |
| 68 |
|
| 69 |
declare i8 @llvm.ctpop.i8(i8) nounwind readnone |
| 70 |
declare i16 @llvm.ctpop.i16(i16) nounwind readnone |
| 71 |
declare i32 @llvm.ctpop.i32(i32) nounwind readnone |
| 72 |
declare i64 @llvm.ctpop.i64(i64) nounwind readnone |
| 73 |
declare i64 @llvm.ppc.popcntb(i64) nounwind readnone |