1; RUN: llc < %s -mtriple=ve-unknown-unknown | FileCheck %s
2
3declare i128 @llvm.ctpop.i128(i128)
4declare i64 @llvm.ctpop.i64(i64)
5declare i32 @llvm.ctpop.i32(i32)
6declare i16 @llvm.ctpop.i16(i16)
7declare i8 @llvm.ctpop.i8(i8)
8
9define i128 @func128(i128 %p) {
10; CHECK-LABEL: func128:
11; CHECK:       # %bb.0:
12; CHECK-NEXT:    pcnt %s1, %s1
13; CHECK-NEXT:    pcnt %s0, %s0
14; CHECK-NEXT:    adds.l %s0, %s0, %s1
15; CHECK-NEXT:    or %s1, 0, (0)1
16; CHECK-NEXT:    b.l.t (, %s10)
17  %r = tail call i128 @llvm.ctpop.i128(i128 %p)
18  ret i128 %r
19}
20
21define i64 @func64(i64 %p) {
22; CHECK-LABEL: func64:
23; CHECK:       # %bb.0:
24; CHECK-NEXT:    pcnt %s0, %s0
25; CHECK-NEXT:    b.l.t (, %s10)
26  %r = tail call i64 @llvm.ctpop.i64(i64 %p)
27  ret i64 %r
28}
29
30define signext i32 @func32s(i32 signext %p) {
31; CHECK-LABEL: func32s:
32; CHECK:       # %bb.0:
33; CHECK-NEXT:    and %s0, %s0, (32)0
34; CHECK-NEXT:    pcnt %s0, %s0
35; CHECK-NEXT:    b.l.t (, %s10)
36  %r = tail call i32 @llvm.ctpop.i32(i32 %p)
37  ret i32 %r
38}
39
40define zeroext i32 @func32z(i32 zeroext %p) {
41; CHECK-LABEL: func32z:
42; CHECK:       # %bb.0:
43; CHECK-NEXT:    pcnt %s0, %s0
44; CHECK-NEXT:    b.l.t (, %s10)
45  %r = tail call i32 @llvm.ctpop.i32(i32 %p)
46  ret i32 %r
47}
48
49define signext i16 @func16s(i16 signext %p) {
50; CHECK-LABEL: func16s:
51; CHECK:       # %bb.0:
52; CHECK-NEXT:    and %s0, %s0, (48)0
53; CHECK-NEXT:    pcnt %s0, %s0
54; CHECK-NEXT:    b.l.t (, %s10)
55  %r = tail call i16 @llvm.ctpop.i16(i16 %p)
56  ret i16 %r
57}
58
59define zeroext i16 @func16z(i16 zeroext %p) {
60; CHECK-LABEL: func16z:
61; CHECK:       # %bb.0:
62; CHECK-NEXT:    pcnt %s0, %s0
63; CHECK-NEXT:    b.l.t (, %s10)
64  %r = tail call i16 @llvm.ctpop.i16(i16 %p)
65  ret i16 %r
66}
67
68define signext i8 @func8s(i8 signext %p) {
69; CHECK-LABEL: func8s:
70; CHECK:       # %bb.0:
71; CHECK-NEXT:    and %s0, %s0, (56)0
72; CHECK-NEXT:    pcnt %s0, %s0
73; CHECK-NEXT:    b.l.t (, %s10)
74  %r = tail call i8 @llvm.ctpop.i8(i8 %p)
75  ret i8 %r
76}
77
78define zeroext i8 @func8z(i8 zeroext %p) {
79; CHECK-LABEL: func8z:
80; CHECK:       # %bb.0:
81; CHECK-NEXT:    pcnt %s0, %s0
82; CHECK-NEXT:    b.l.t (, %s10)
83  %r = tail call i8 @llvm.ctpop.i8(i8 %p)
84  ret i8 %r
85}
86
87define i128 @func128i() {
88; CHECK-LABEL: func128i:
89; CHECK:       # %bb.0:
90; CHECK-NEXT:    or %s0, 16, (0)1
91; CHECK-NEXT:    or %s1, 0, (0)1
92; CHECK-NEXT:    b.l.t (, %s10)
93  %r = tail call i128 @llvm.ctpop.i128(i128 65535)
94  ret i128 %r
95}
96
97define i64 @func64i() {
98; CHECK-LABEL: func64i:
99; CHECK:       # %bb.0:
100; CHECK-NEXT:    or %s0, 16, (0)1
101; CHECK-NEXT:    b.l.t (, %s10)
102  %r = tail call i64 @llvm.ctpop.i64(i64 65535)
103  ret i64 %r
104}
105
106define signext i32 @func32is() {
107; CHECK-LABEL: func32is:
108; CHECK:       # %bb.0:
109; CHECK-NEXT:    or %s0, 16, (0)1
110; CHECK-NEXT:    b.l.t (, %s10)
111  %r = tail call i32 @llvm.ctpop.i32(i32 65535)
112  ret i32 %r
113}
114
115define zeroext i32 @func32iz() {
116; CHECK-LABEL: func32iz:
117; CHECK:       # %bb.0:
118; CHECK-NEXT:    or %s0, 16, (0)1
119; CHECK-NEXT:    b.l.t (, %s10)
120  %r = tail call i32 @llvm.ctpop.i32(i32 65535)
121  ret i32 %r
122}
123
124define signext i16 @func16si() {
125; CHECK-LABEL: func16si:
126; CHECK:       # %bb.0:
127; CHECK-NEXT:    or %s0, 16, (0)1
128; CHECK-NEXT:    b.l.t (, %s10)
129  %r = tail call i16 @llvm.ctpop.i16(i16 65535)
130  ret i16 %r
131}
132
133define zeroext i16 @func16zi() {
134; CHECK-LABEL: func16zi:
135; CHECK:       # %bb.0:
136; CHECK-NEXT:    or %s0, 16, (0)1
137; CHECK-NEXT:    b.l.t (, %s10)
138  %r = tail call i16 @llvm.ctpop.i16(i16 65535)
139  ret i16 %r
140}
141
142define signext i8 @func8si() {
143; CHECK-LABEL: func8si:
144; CHECK:       # %bb.0:
145; CHECK-NEXT:    or %s0, 8, (0)1
146; CHECK-NEXT:    b.l.t (, %s10)
147  %r = tail call i8 @llvm.ctpop.i8(i8 255)
148  ret i8 %r
149}
150
151define zeroext i8 @func8zi() {
152; CHECK-LABEL: func8zi:
153; CHECK:       # %bb.0:
154; CHECK-NEXT:    or %s0, 8, (0)1
155; CHECK-NEXT:    b.l.t (, %s10)
156  %r = tail call i8 @llvm.ctpop.i8(i8 255)
157  ret i8 %r
158}
159