1 # NOTE: Assertions have been autogenerated by utils/update_mir_test_checks.py
2 # RUN: llc -mtriple=x86_64-linux-gnu -run-pass=instruction-select -verify-machineinstrs %s -o - | FileCheck %s --check-prefix=ALL
5 define i64 @test_ashr_i64(i64 %arg1, i64 %arg2) {
6 %res = ashr i64 %arg1, %arg2
10 define i64 @test_ashr_i64_imm(i64 %arg1) {
11 %res = ashr i64 %arg1, 5
15 define i32 @test_ashr_i32(i32 %arg1, i32 %arg2) {
16 %res = ashr i32 %arg1, %arg2
20 define i32 @test_ashr_i32_imm(i32 %arg1) {
21 %res = ashr i32 %arg1, 5
25 define i16 @test_ashr_i16(i32 %arg1, i32 %arg2) {
26 %a = trunc i32 %arg1 to i16
27 %a2 = trunc i32 %arg2 to i16
28 %res = ashr i16 %a, %a2
32 define i16 @test_ashr_i16_imm(i32 %arg1) {
33 %a = trunc i32 %arg1 to i16
38 define i8 @test_ashr_i8(i32 %arg1, i32 %arg2) {
39 %a = trunc i32 %arg1 to i8
40 %a2 = trunc i32 %arg2 to i8
41 %res = ashr i8 %a, %a2
45 define i8 @test_ashr_i8_imm(i32 %arg1) {
46 %a = trunc i32 %arg1 to i8
56 tracksRegLiveness: true
58 - { id: 0, class: gpr, preferred-register: '' }
59 - { id: 1, class: gpr, preferred-register: '' }
60 - { id: 2, class: gpr, preferred-register: '' }
61 - { id: 3, class: gpr, preferred-register: '' }
70 ; ALL-LABEL: name: test_ashr_i64
71 ; ALL: liveins: $rdi, $rsi
73 ; ALL-NEXT: [[COPY:%[0-9]+]]:gr64 = COPY $rdi
74 ; ALL-NEXT: [[COPY1:%[0-9]+]]:gr64_with_sub_8bit = COPY $rsi
75 ; ALL-NEXT: [[COPY2:%[0-9]+]]:gr8 = COPY [[COPY1]].sub_8bit
76 ; ALL-NEXT: $cl = COPY [[COPY2]]
77 ; ALL-NEXT: [[SAR64rCL:%[0-9]+]]:gr64 = SAR64rCL [[COPY]], implicit-def dead $eflags, implicit $cl
78 ; ALL-NEXT: $rax = COPY [[SAR64rCL]]
79 ; ALL-NEXT: RET 0, implicit $rax
83 %3(s64) = G_ASHR %0, %2
89 name: test_ashr_i64_imm
93 tracksRegLiveness: true
95 - { id: 0, class: gpr, preferred-register: '' }
96 - { id: 1, class: gpr, preferred-register: '' }
97 - { id: 2, class: gpr, preferred-register: '' }
106 ; ALL-LABEL: name: test_ashr_i64_imm
109 ; ALL-NEXT: [[COPY:%[0-9]+]]:gr64 = COPY $rdi
110 ; ALL-NEXT: [[SAR64ri:%[0-9]+]]:gr64 = SAR64ri [[COPY]], 5, implicit-def dead $eflags
111 ; ALL-NEXT: $rax = COPY [[SAR64ri]]
112 ; ALL-NEXT: RET 0, implicit $rax
114 %1(s8) = G_CONSTANT i8 5
115 %2(s64) = G_ASHR %0, %1
124 regBankSelected: true
125 tracksRegLiveness: true
127 - { id: 0, class: gpr, preferred-register: '' }
128 - { id: 1, class: gpr, preferred-register: '' }
129 - { id: 2, class: gpr, preferred-register: '' }
130 - { id: 3, class: gpr, preferred-register: '' }
139 ; ALL-LABEL: name: test_ashr_i32
140 ; ALL: liveins: $edi, $esi
142 ; ALL-NEXT: [[COPY:%[0-9]+]]:gr32 = COPY $edi
143 ; ALL-NEXT: [[COPY1:%[0-9]+]]:gr32 = COPY $esi
144 ; ALL-NEXT: [[COPY2:%[0-9]+]]:gr8 = COPY [[COPY1]].sub_8bit
145 ; ALL-NEXT: $cl = COPY [[COPY2]]
146 ; ALL-NEXT: [[SAR32rCL:%[0-9]+]]:gr32 = SAR32rCL [[COPY]], implicit-def dead $eflags, implicit $cl
147 ; ALL-NEXT: $eax = COPY [[SAR32rCL]]
148 ; ALL-NEXT: RET 0, implicit $eax
152 %3(s32) = G_ASHR %0, %2
158 name: test_ashr_i32_imm
161 regBankSelected: true
162 tracksRegLiveness: true
164 - { id: 0, class: gpr, preferred-register: '' }
165 - { id: 1, class: gpr, preferred-register: '' }
166 - { id: 2, class: gpr, preferred-register: '' }
175 ; ALL-LABEL: name: test_ashr_i32_imm
178 ; ALL-NEXT: [[COPY:%[0-9]+]]:gr32 = COPY $edi
179 ; ALL-NEXT: [[SAR32ri:%[0-9]+]]:gr32 = SAR32ri [[COPY]], 5, implicit-def dead $eflags
180 ; ALL-NEXT: $eax = COPY [[SAR32ri]]
181 ; ALL-NEXT: RET 0, implicit $eax
183 %1(s8) = G_CONSTANT i8 5
184 %2(s32) = G_ASHR %0, %1
193 regBankSelected: true
194 tracksRegLiveness: true
196 - { id: 0, class: gpr, preferred-register: '' }
197 - { id: 1, class: gpr, preferred-register: '' }
198 - { id: 2, class: gpr, preferred-register: '' }
199 - { id: 3, class: gpr, preferred-register: '' }
200 - { id: 4, class: gpr, preferred-register: '' }
209 ; ALL-LABEL: name: test_ashr_i16
210 ; ALL: liveins: $edi, $esi
212 ; ALL-NEXT: [[COPY:%[0-9]+]]:gr32 = COPY $edi
213 ; ALL-NEXT: [[COPY1:%[0-9]+]]:gr32 = COPY $esi
214 ; ALL-NEXT: [[COPY2:%[0-9]+]]:gr16 = COPY [[COPY]].sub_16bit
215 ; ALL-NEXT: [[COPY3:%[0-9]+]]:gr8 = COPY [[COPY1]].sub_8bit
216 ; ALL-NEXT: $cl = COPY [[COPY3]]
217 ; ALL-NEXT: [[SAR16rCL:%[0-9]+]]:gr16 = SAR16rCL [[COPY2]], implicit-def dead $eflags, implicit $cl
218 ; ALL-NEXT: $ax = COPY [[SAR16rCL]]
219 ; ALL-NEXT: RET 0, implicit $ax
222 %2(s16) = G_TRUNC %0(s32)
223 %3(s8) = G_TRUNC %1(s32)
224 %4(s16) = G_ASHR %2, %3
230 name: test_ashr_i16_imm
233 regBankSelected: true
234 tracksRegLiveness: true
236 - { id: 0, class: gpr, preferred-register: '' }
237 - { id: 1, class: gpr, preferred-register: '' }
238 - { id: 2, class: gpr, preferred-register: '' }
239 - { id: 3, class: gpr, preferred-register: '' }
248 ; ALL-LABEL: name: test_ashr_i16_imm
251 ; ALL-NEXT: [[COPY:%[0-9]+]]:gr32 = COPY $edi
252 ; ALL-NEXT: [[COPY1:%[0-9]+]]:gr16 = COPY [[COPY]].sub_16bit
253 ; ALL-NEXT: [[SAR16ri:%[0-9]+]]:gr16 = SAR16ri [[COPY1]], 5, implicit-def dead $eflags
254 ; ALL-NEXT: $ax = COPY [[SAR16ri]]
255 ; ALL-NEXT: RET 0, implicit $ax
257 %2(s8) = G_CONSTANT i8 5
258 %1(s16) = G_TRUNC %0(s32)
259 %3(s16) = G_ASHR %1, %2
268 regBankSelected: true
269 tracksRegLiveness: true
271 - { id: 0, class: gpr, preferred-register: '' }
272 - { id: 1, class: gpr, preferred-register: '' }
273 - { id: 2, class: gpr, preferred-register: '' }
274 - { id: 3, class: gpr, preferred-register: '' }
275 - { id: 4, class: gpr, preferred-register: '' }
284 ; ALL-LABEL: name: test_ashr_i8
285 ; ALL: liveins: $edi, $esi
287 ; ALL-NEXT: [[COPY:%[0-9]+]]:gr32 = COPY $edi
288 ; ALL-NEXT: [[COPY1:%[0-9]+]]:gr32 = COPY $esi
289 ; ALL-NEXT: [[COPY2:%[0-9]+]]:gr8 = COPY [[COPY]].sub_8bit
290 ; ALL-NEXT: [[COPY3:%[0-9]+]]:gr8 = COPY [[COPY1]].sub_8bit
291 ; ALL-NEXT: $cl = COPY [[COPY3]]
292 ; ALL-NEXT: [[SAR8rCL:%[0-9]+]]:gr8 = SAR8rCL [[COPY2]], implicit-def dead $eflags, implicit $cl
293 ; ALL-NEXT: $al = COPY [[SAR8rCL]]
294 ; ALL-NEXT: RET 0, implicit $al
297 %2(s8) = G_TRUNC %0(s32)
298 %3(s8) = G_TRUNC %1(s32)
299 %4(s8) = G_ASHR %2, %3
305 name: test_ashr_i8_imm
308 regBankSelected: true
309 tracksRegLiveness: true
311 - { id: 0, class: gpr, preferred-register: '' }
312 - { id: 1, class: gpr, preferred-register: '' }
313 - { id: 2, class: gpr, preferred-register: '' }
314 - { id: 3, class: gpr, preferred-register: '' }
323 ; ALL-LABEL: name: test_ashr_i8_imm
326 ; ALL-NEXT: [[COPY:%[0-9]+]]:gr32 = COPY $edi
327 ; ALL-NEXT: [[COPY1:%[0-9]+]]:gr8 = COPY [[COPY]].sub_8bit
328 ; ALL-NEXT: [[SAR8ri:%[0-9]+]]:gr8 = SAR8ri [[COPY1]], 5, implicit-def dead $eflags
329 ; ALL-NEXT: $al = COPY [[SAR8ri]]
330 ; ALL-NEXT: RET 0, implicit $al
332 %2(s8) = G_CONSTANT i8 5
333 %1(s8) = G_TRUNC %0(s32)
334 %3(s8) = G_ASHR %1, %2