• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1; Test population-count instruction on z15
2;
3; RUN: llc < %s -mtriple=s390x-linux-gnu -mcpu=z15 | FileCheck %s
4
5declare i32 @llvm.ctpop.i32(i32 %a)
6declare i64 @llvm.ctpop.i64(i64 %a)
7
8define i32 @f1(i32 %a) {
9; CHECK-LABEL: f1:
10; CHECK: llgfr   %r0, %r2
11; CHECK: popcnt  %r2, %r0, 8
12; CHECK: br      %r14
13
14  %popcnt = call i32 @llvm.ctpop.i32(i32 %a)
15  ret i32 %popcnt
16}
17
18define i32 @f2(i32 %a) {
19; CHECK-LABEL: f2:
20; CHECK: llghr   %r0, %r2
21; CHECK: popcnt  %r2, %r0, 8
22; CHECK: br      %r14
23  %and = and i32 %a, 65535
24  %popcnt = call i32 @llvm.ctpop.i32(i32 %and)
25  ret i32 %popcnt
26}
27
28define i32 @f3(i32 %a) {
29; CHECK-LABEL: f3:
30; CHECK: llgcr   %r0, %r2
31; CHECK: popcnt  %r2, %r0, 8
32; CHECK: br      %r14
33  %and = and i32 %a, 255
34  %popcnt = call i32 @llvm.ctpop.i32(i32 %and)
35  ret i32 %popcnt
36}
37
38define i64 @f4(i64 %a) {
39; CHECK-LABEL: f4:
40; CHECK: popcnt  %r2, %r2, 8
41; CHECK: br      %r14
42  %popcnt = call i64 @llvm.ctpop.i64(i64 %a)
43  ret i64 %popcnt
44}
45
46define i64 @f5(i64 %a) {
47; CHECK-LABEL: f5:
48; CHECK: llgfr   %r0, %r2
49; CHECK: popcnt  %r2, %r0, 8
50  %and = and i64 %a, 4294967295
51  %popcnt = call i64 @llvm.ctpop.i64(i64 %and)
52  ret i64 %popcnt
53}
54
55define i64 @f6(i64 %a) {
56; CHECK-LABEL: f6:
57; CHECK: llghr   %r0, %r2
58; CHECK: popcnt  %r2, %r0, 8
59; CHECK: br      %r14
60  %and = and i64 %a, 65535
61  %popcnt = call i64 @llvm.ctpop.i64(i64 %and)
62  ret i64 %popcnt
63}
64
65define i64 @f7(i64 %a) {
66; CHECK-LABEL: f7:
67; CHECK: llgcr   %r0, %r2
68; CHECK: popcnt  %r2, %r0, 8
69; CHECK: br      %r14
70  %and = and i64 %a, 255
71  %popcnt = call i64 @llvm.ctpop.i64(i64 %and)
72  ret i64 %popcnt
73}
74
75