1 ; RUN: llc -verify-machineinstrs -mcpu=pwr7 < %s | FileCheck %s
2 target datalayout = "E-m:e-i64:64-n32:64"
3 target triple = "powerpc64-unknown-linux-gnu"
5 ; Function Attrs: nounwind readnone
6 define zeroext i32 @bs4(i32 zeroext %a) #0 {
8 %0 = tail call i32 @llvm.bswap.i32(i32 %a)
12 ; CHECK: rotlwi [[REG1:[0-9]+]], 3, 8
13 ; CHECK: rlwimi [[REG1]], 3, 24, 16, 23
14 ; CHECK: rlwimi [[REG1]], 3, 24, 0, 7
15 ; CHECK: mr 3, [[REG1]]
19 define i64 @bs8(i64 %x) #0 {
21 %0 = tail call i64 @llvm.bswap.i64(i64 %x)
25 ; CHECK-DAG: rotldi [[REG1:[0-9]+]], 3, 16
26 ; CHECK-DAG: rotldi [[REG2:[0-9]+]], 3, 8
27 ; CHECK-DAG: rotldi [[REG3:[0-9]+]], 3, 24
28 ; CHECK-DAG: rldimi [[REG2]], [[REG1]], 8, 48
29 ; CHECK-DAG: rotldi [[REG4:[0-9]+]], 3, 32
30 ; CHECK-DAG: rldimi [[REG2]], [[REG3]], 16, 40
31 ; CHECK-DAG: rotldi [[REG5:[0-9]+]], 3, 48
32 ; CHECK-DAG: rldimi [[REG2]], [[REG4]], 24, 32
33 ; CHECK-DAG: rotldi [[REG6:[0-9]+]], 3, 56
34 ; CHECK-DAG: rldimi [[REG2]], [[REG5]], 40, 16
35 ; CHECK-DAG: rldimi [[REG2]], [[REG6]], 48, 8
36 ; CHECK-DAG: rldimi [[REG2]], 3, 56, 0
37 ; CHECK: mr 3, [[REG2]]
41 define i64 @test1(i64 %i0, i64 %i1) #0 {
44 %and = and i64 %0, 5963776000
48 ; CHECK-DAG: li [[REG1:[0-9]+]], 11375
49 ; CHECK-DAG: rotldi [[REG3:[0-9]+]], 4, 56
50 ; CHECK-DAG: rldic [[REG2:[0-9]+]], [[REG1]], 19, 31
51 ; CHECK: and 3, [[REG3]], [[REG2]]
55 define i64 @test2(i64 %i0, i64 %i1) #0 {
58 %and = and i64 %0, 133434808670355456
62 ; CHECK-DAG: lis [[REG1:[0-9]+]], 7
63 ; CHECK-DAG: rotldi [[REG5:[0-9]+]], 4, 58
64 ; CHECK-DAG: ori [[REG2:[0-9]+]], [[REG1]], 26681
65 ; CHECK-DAG: rldic [[REG3:[0-9]+]], [[REG2]], 38, 7
66 ; CHECK-DAG: oris [[REG4:[0-9]+]], [[REG3]], 25464
67 ; CHECK: and 3, [[REG5]], [[REG4]]
71 define i64 @test3(i64 %i0, i64 %i1) #0 {
74 %and = and i64 %0, 191795733152661504
78 ; CHECK-DAG: lis [[REG1:[0-9]+]], 170
79 ; CHECK-DAG: rotldi [[REG4:[0-9]+]], 3, 34
80 ; CHECK-DAG: ori [[REG2:[0-9]+]], [[REG1]], 22861
81 ; CHECK-DAG: rldic [[REG3:[0-9]+]], [[REG2]], 34, 6
82 ; CHECK: and 3, [[REG4]], [[REG3]]
86 define i64 @test4(i64 %i0, i64 %i1) #0 {
89 %and = and i64 %0, 58195968
93 ; CHECK: rotldi [[REG1:[0-9]+]], 4, 49
94 ; CHECK: andis. 3, [[REG1]], 888
98 define i64 @test5(i64 %i0, i64 %i1) #0 {
101 %and = and i64 %0, 127252959854592
104 ; CHECK-LABEL: @test5
105 ; CHECK-DAG: lis [[REG1:[0-9]+]], 3703
106 ; CHECK-DAG: rotldi [[REG4:[0-9]+]], 4, 12
107 ; CHECK-DAG: ori [[REG2:[0-9]+]], [[REG1]], 35951
108 ; CHECK-DAG: rldic [[REG3:[0-9]+]], [[REG2]], 19, 17
109 ; CHECK: and 3, [[REG4]], [[REG3]]
113 ; Function Attrs: nounwind readnone
114 define zeroext i32 @test6(i32 zeroext %x) #0 {
116 %and = lshr i32 %x, 16
117 %shr = and i32 %and, 255
118 %and1 = shl i32 %x, 16
119 %shl = and i32 %and1, 16711680
120 %or = or i32 %shr, %shl
123 ; CHECK-LABEL: @test6
124 ; CHECK: rlwinm [[REG1:[0-9]+]], 3, 16, 24, 31
125 ; CHECK: rlwimi [[REG1]], 3, 16, 8, 15
126 ; CHECK: mr 3, [[REG1]]
130 define i64 @test7(i64 %i0, i64 %i1) #0 {
133 %and = and i64 %0, 58195968
136 ; CHECK-LABEL: @test7
137 ; CHECK: rlwinm [[REG1:[0-9]+]], 3, 27, 9, 12
138 ; CHECK: rlwimi [[REG1]], 3, 27, 6, 7
139 ; CHECK: mr 3, [[REG1]]
143 define i64 @test8(i64 %i0, i64 %i1) #0 {
146 %and = and i64 %0, 169172533248
149 ; CHECK-LABEL: @test8
150 ; CHECK-DAG: lis [[REG1:[0-9]+]], 4
151 ; CHECK-DAG: rotldi [[REG4:[0-9]+]], 3, 63
152 ; CHECK-DAG: ori [[REG2:[0-9]+]], [[REG1]], 60527
153 ; CHECK-DAG: rldic [[REG3:[0-9]+]], [[REG2]], 19, 26
154 ; CHECK: and 3, [[REG4]], [[REG3]]
158 define i64 @test9(i64 %i0, i64 %i1) #0 {
160 %0 = lshr i64 %i1, 14
161 %and = and i64 %0, 18848677888
163 %and3 = and i64 %1, 405323966463344640
164 %or4 = or i64 %and, %and3
167 ; CHECK-LABEL: @test9
168 ; CHECK-DAG: lis [[REG1:[0-9]+]], 360
169 ; CHECK-DAG: rotldi [[REG5:[0-9]+]], 4, 62
170 ; CHECK-DAG: rotldi [[REG6:[0-9]+]], 4, 50
171 ; CHECK-DAG: ori [[REG2:[0-9]+]], [[REG1]], 1
172 ; CHECK-DAG: rldimi [[REG6]], [[REG5]], 53, 0
173 ; CHECK-DAG: rldic [[REG3:[0-9]+]], [[REG2]], 34, 5
174 ; CHECK-DAG: oris [[REG4:[0-9]+]], [[REG3]], 25464
175 ; CHECK: and 3, [[REG6]], [[REG4]]
179 define i64 @test10(i64 %i0, i64 %i1) #0 {
182 %and = and i64 %0, 15881483390550016
184 %and3 = and i64 %1, 2473599172608
185 %or4 = or i64 %and, %and3
188 ; CHECK-LABEL: @test10
189 ; CHECK-DAG: lis [[REG1:[0-9]+]], 1
190 ; CHECK-DAG: rotldi [[REG6:[0-9]+]], 3, 25
191 ; CHECK-DAG: rotldi [[REG7:[0-9]+]], 3, 37
192 ; CHECK-DAG: ori [[REG2:[0-9]+]], [[REG1]], 8183
193 ; CHECK-DAG: li [[REG3:[0-9]+]], -15519
194 ; CHECK-DAG: rldic [[REG4:[0-9]+]], [[REG2]], 25, 22
195 ; CHECK-DAG: rldic [[REG5:[0-9]+]], [[REG3]], 37, 10
196 ; CHECK-DAG: and [[REG8:[0-9]+]], [[REG6]], [[REG4]]
197 ; CHECK-DAG: and [[REG9:[0-9]+]], [[REG7]], [[REG5]]
198 ; CHECK: or 3, [[REG9]], [[REG8]]
202 define i64 @test11(i64 %x) #0 {
204 %and = and i64 %x, 4294967295
205 %shl = shl i64 %x, 32
206 %or = or i64 %and, %shl
209 ; CHECK-LABEL: @test11
210 ; CHECK: rlwinm 3, 3, 0, 1, 0
214 define i64 @test12(i64 %x) #0 {
216 %and = and i64 %x, 4294905855
217 %shl = shl i64 %x, 32
218 %or = or i64 %and, %shl
221 ; CHECK-LABEL: @test12
222 ; CHECK: rlwinm 3, 3, 0, 20, 15
226 define i64 @test13(i64 %x) #0 {
229 %and = and i64 %shl, 240
230 %shr = lshr i64 %x, 28
231 %and1 = and i64 %shr, 15
232 %or = or i64 %and, %and1
235 ; CHECK-LABEL: @test13
236 ; CHECK: rlwinm 3, 3, 4, 24, 31
240 define i64 @test14(i64 %x) #0 {
243 %and = and i64 %shl, 240
244 %shr = lshr i64 %x, 28
245 %and1 = and i64 %shr, 15
246 %and2 = and i64 %x, -4294967296
247 %or = or i64 %and1, %and2
248 %or3 = or i64 %or, %and
251 ; CHECK-LABEL: @test14
252 ; CHECK: rldicr [[REG1:[0-9]+]], 3, 0, 31
253 ; CHECK: rlwimi [[REG1]], 3, 4, 24, 31
254 ; CHECK: mr 3, [[REG1]]
258 define i64 @test15(i64 %x) #0 {
261 %and = and i64 %shl, 240
262 %shr = lshr i64 %x, 28
263 %and1 = and i64 %shr, 15
264 %and2 = and i64 %x, -256
265 %or = or i64 %and1, %and2
266 %or3 = or i64 %or, %and
269 ; CHECK-LABEL: @test15
270 ; CHECK: rlwimi 3, 3, 4, 24, 31
274 define i64 @test16(i64 %a, i64 %b) #0 {
276 %and = and i64 %a, 4294967295
277 %shl = shl i64 %b, 32
278 %or = or i64 %and, %shl
281 ; CHECK-LABEL: @test16
282 ; CHECK: rldimi 3, 4, 32, 0
286 ; Function Attrs: nounwind readnone
287 declare i32 @llvm.bswap.i32(i32) #0
288 declare i64 @llvm.bswap.i64(i64) #0
290 attributes #0 = { nounwind readnone }