1 ; NOTE: Assertions have been autogenerated by utils/update_llc_test_checks.py
2 ; RUN: llc -verify-machineinstrs -mtriple=powerpc -mcpu=ppc32 < %s | FileCheck %s --check-prefix=PPC32
3 ; RUN: llc -verify-machineinstrs -mtriple=powerpc64-unknown-linux-gnu -mcpu=pwr8 < %s | FileCheck %s
4 ; RUN: llc -verify-machineinstrs -mtriple=powerpc64le-unknown-linux-gnu -mcpu=pwr8 < %s | FileCheck %s
5 declare i32 @llvm.bitreverse.i32(i32)
6 define i32 @testBitReverseIntrinsicI32(i32 %arg) {
7 ; PPC32-LABEL: testBitReverseIntrinsicI32:
9 ; PPC32-NEXT: lis 4, -21846
10 ; PPC32-NEXT: ori 4, 4, 43690
11 ; PPC32-NEXT: slwi 5, 3, 1
12 ; PPC32-NEXT: and 4, 5, 4
13 ; PPC32-NEXT: lis 5, 21845
14 ; PPC32-NEXT: ori 5, 5, 21845
15 ; PPC32-NEXT: srwi 3, 3, 1
16 ; PPC32-NEXT: and 3, 3, 5
17 ; PPC32-NEXT: lis 5, -13108
18 ; PPC32-NEXT: or 3, 3, 4
19 ; PPC32-NEXT: ori 5, 5, 52428
20 ; PPC32-NEXT: slwi 4, 3, 2
21 ; PPC32-NEXT: and 4, 4, 5
22 ; PPC32-NEXT: lis 5, 13107
23 ; PPC32-NEXT: ori 5, 5, 13107
24 ; PPC32-NEXT: srwi 3, 3, 2
25 ; PPC32-NEXT: and 3, 3, 5
26 ; PPC32-NEXT: lis 5, -3856
27 ; PPC32-NEXT: or 3, 3, 4
28 ; PPC32-NEXT: ori 5, 5, 61680
29 ; PPC32-NEXT: slwi 4, 3, 4
30 ; PPC32-NEXT: and 4, 4, 5
31 ; PPC32-NEXT: lis 5, 3855
32 ; PPC32-NEXT: ori 5, 5, 3855
33 ; PPC32-NEXT: srwi 3, 3, 4
34 ; PPC32-NEXT: and 3, 3, 5
35 ; PPC32-NEXT: or 4, 3, 4
36 ; PPC32-NEXT: rotlwi 3, 4, 24
37 ; PPC32-NEXT: rlwimi 3, 4, 8, 8, 15
38 ; PPC32-NEXT: rlwimi 3, 4, 8, 24, 31
41 ; CHECK-LABEL: testBitReverseIntrinsicI32:
43 ; CHECK-NEXT: lis 4, -21846
44 ; CHECK-NEXT: slwi 5, 3, 1
45 ; CHECK-NEXT: srwi 3, 3, 1
46 ; CHECK-NEXT: ori 4, 4, 43690
47 ; CHECK-NEXT: and 4, 5, 4
48 ; CHECK-NEXT: lis 5, 21845
49 ; CHECK-NEXT: ori 5, 5, 21845
50 ; CHECK-NEXT: and 3, 3, 5
51 ; CHECK-NEXT: lis 5, -13108
52 ; CHECK-NEXT: or 3, 3, 4
53 ; CHECK-NEXT: ori 5, 5, 52428
54 ; CHECK-NEXT: slwi 4, 3, 2
55 ; CHECK-NEXT: srwi 3, 3, 2
56 ; CHECK-NEXT: and 4, 4, 5
57 ; CHECK-NEXT: lis 5, 13107
58 ; CHECK-NEXT: ori 5, 5, 13107
59 ; CHECK-NEXT: and 3, 3, 5
60 ; CHECK-NEXT: lis 5, -3856
61 ; CHECK-NEXT: or 3, 3, 4
62 ; CHECK-NEXT: ori 5, 5, 61680
63 ; CHECK-NEXT: slwi 4, 3, 4
64 ; CHECK-NEXT: srwi 3, 3, 4
65 ; CHECK-NEXT: and 4, 4, 5
66 ; CHECK-NEXT: lis 5, 3855
67 ; CHECK-NEXT: ori 5, 5, 3855
68 ; CHECK-NEXT: and 3, 3, 5
69 ; CHECK-NEXT: or 3, 3, 4
70 ; CHECK-NEXT: rotlwi 4, 3, 24
71 ; CHECK-NEXT: rlwimi 4, 3, 8, 8, 15
72 ; CHECK-NEXT: rlwimi 4, 3, 8, 24, 31
73 ; CHECK-NEXT: rldicl 3, 4, 0, 32
75 %res = call i32 @llvm.bitreverse.i32(i32 %arg)
79 declare i64 @llvm.bitreverse.i64(i64)
80 define i64 @testBitReverseIntrinsicI64(i64 %arg) {
81 ; PPC32-LABEL: testBitReverseIntrinsicI64:
83 ; PPC32-NEXT: lis 5, -21846
84 ; PPC32-NEXT: lis 6, 21845
85 ; PPC32-NEXT: ori 5, 5, 43690
86 ; PPC32-NEXT: slwi 10, 4, 1
87 ; PPC32-NEXT: slwi 11, 3, 1
88 ; PPC32-NEXT: ori 6, 6, 21845
89 ; PPC32-NEXT: srwi 4, 4, 1
90 ; PPC32-NEXT: srwi 3, 3, 1
91 ; PPC32-NEXT: and 10, 10, 5
92 ; PPC32-NEXT: and 5, 11, 5
93 ; PPC32-NEXT: and 4, 4, 6
94 ; PPC32-NEXT: and 3, 3, 6
95 ; PPC32-NEXT: lis 7, -13108
96 ; PPC32-NEXT: lis 8, 13107
97 ; PPC32-NEXT: or 4, 4, 10
98 ; PPC32-NEXT: or 3, 3, 5
99 ; PPC32-NEXT: ori 7, 7, 52428
100 ; PPC32-NEXT: ori 8, 8, 13107
101 ; PPC32-NEXT: slwi 5, 4, 2
102 ; PPC32-NEXT: srwi 4, 4, 2
103 ; PPC32-NEXT: slwi 6, 3, 2
104 ; PPC32-NEXT: srwi 3, 3, 2
105 ; PPC32-NEXT: and 5, 5, 7
106 ; PPC32-NEXT: and 4, 4, 8
107 ; PPC32-NEXT: and 6, 6, 7
108 ; PPC32-NEXT: and 3, 3, 8
109 ; PPC32-NEXT: lis 9, -3856
110 ; PPC32-NEXT: lis 11, 3855
111 ; PPC32-NEXT: or 4, 4, 5
112 ; PPC32-NEXT: or 3, 3, 6
113 ; PPC32-NEXT: ori 9, 9, 61680
114 ; PPC32-NEXT: ori 11, 11, 3855
115 ; PPC32-NEXT: slwi 5, 4, 4
116 ; PPC32-NEXT: srwi 4, 4, 4
117 ; PPC32-NEXT: slwi 6, 3, 4
118 ; PPC32-NEXT: srwi 3, 3, 4
119 ; PPC32-NEXT: and 5, 5, 9
120 ; PPC32-NEXT: and 4, 4, 11
121 ; PPC32-NEXT: and 6, 6, 9
122 ; PPC32-NEXT: and 3, 3, 11
123 ; PPC32-NEXT: or 5, 4, 5
124 ; PPC32-NEXT: or 6, 3, 6
125 ; PPC32-NEXT: rotlwi 3, 5, 24
126 ; PPC32-NEXT: rotlwi 4, 6, 24
127 ; PPC32-NEXT: rlwimi 3, 5, 8, 8, 15
128 ; PPC32-NEXT: rlwimi 4, 6, 8, 8, 15
129 ; PPC32-NEXT: rlwimi 3, 5, 8, 24, 31
130 ; PPC32-NEXT: rlwimi 4, 6, 8, 24, 31
133 ; CHECK-LABEL: testBitReverseIntrinsicI64:
135 ; CHECK-NEXT: lis 4, -21846
136 ; CHECK-NEXT: sldi 5, 3, 1
137 ; CHECK-NEXT: rldicl 3, 3, 63, 1
138 ; CHECK-NEXT: ori 4, 4, 43690
139 ; CHECK-NEXT: sldi 4, 4, 32
140 ; CHECK-NEXT: oris 4, 4, 43690
141 ; CHECK-NEXT: ori 4, 4, 43690
142 ; CHECK-NEXT: and 4, 5, 4
143 ; CHECK-NEXT: lis 5, 21845
144 ; CHECK-NEXT: ori 5, 5, 21845
145 ; CHECK-NEXT: sldi 5, 5, 32
146 ; CHECK-NEXT: oris 5, 5, 21845
147 ; CHECK-NEXT: ori 5, 5, 21845
148 ; CHECK-NEXT: and 3, 3, 5
149 ; CHECK-NEXT: lis 5, -13108
150 ; CHECK-NEXT: ori 5, 5, 52428
151 ; CHECK-NEXT: or 3, 3, 4
152 ; CHECK-NEXT: sldi 5, 5, 32
153 ; CHECK-NEXT: sldi 4, 3, 2
154 ; CHECK-NEXT: rldicl 3, 3, 62, 2
155 ; CHECK-NEXT: oris 5, 5, 52428
156 ; CHECK-NEXT: ori 5, 5, 52428
157 ; CHECK-NEXT: and 4, 4, 5
158 ; CHECK-NEXT: lis 5, 13107
159 ; CHECK-NEXT: ori 5, 5, 13107
160 ; CHECK-NEXT: sldi 5, 5, 32
161 ; CHECK-NEXT: oris 5, 5, 13107
162 ; CHECK-NEXT: ori 5, 5, 13107
163 ; CHECK-NEXT: and 3, 3, 5
164 ; CHECK-NEXT: lis 5, -3856
165 ; CHECK-NEXT: ori 5, 5, 61680
166 ; CHECK-NEXT: or 3, 3, 4
167 ; CHECK-NEXT: sldi 5, 5, 32
168 ; CHECK-NEXT: sldi 4, 3, 4
169 ; CHECK-NEXT: rldicl 3, 3, 60, 4
170 ; CHECK-NEXT: oris 5, 5, 61680
171 ; CHECK-NEXT: ori 5, 5, 61680
172 ; CHECK-NEXT: and 4, 4, 5
173 ; CHECK-NEXT: lis 5, 3855
174 ; CHECK-NEXT: ori 5, 5, 3855
175 ; CHECK-NEXT: sldi 5, 5, 32
176 ; CHECK-NEXT: oris 5, 5, 3855
177 ; CHECK-NEXT: ori 5, 5, 3855
178 ; CHECK-NEXT: and 3, 3, 5
179 ; CHECK-NEXT: or 3, 3, 4
180 ; CHECK-NEXT: rldicl 4, 3, 32, 32
181 ; CHECK-NEXT: rotlwi 5, 4, 24
182 ; CHECK-NEXT: rlwimi 5, 4, 8, 8, 15
183 ; CHECK-NEXT: rlwimi 5, 4, 8, 24, 31
184 ; CHECK-NEXT: rotlwi 4, 3, 24
185 ; CHECK-NEXT: rlwimi 4, 3, 8, 8, 15
186 ; CHECK-NEXT: rlwimi 4, 3, 8, 24, 31
187 ; CHECK-NEXT: sldi 3, 4, 32
188 ; CHECK-NEXT: or 3, 3, 5
190 %res = call i64 @llvm.bitreverse.i64(i64 %arg)