1 # NOTE: Assertions have been autogenerated by utils/update_mir_test_checks.py
2 # RUN: llc -run-pass x86-fixup-LEAs -mtriple=i386 -verify-machineinstrs -mcpu=corei7-avx -o - %s | FileCheck %s
4 ; ModuleID = 'test/CodeGen/X86/fixup-lea.ll'
5 source_filename = "test/CodeGen/X86/fixup-lea.ll"
6 target datalayout = "e-m:e-p:32:32-f64:32:64-f80:32-n8:16:32-S128"
8 ;generated using: llc -stop-after x86-pad-short-functions fixup-lea.ll > leaFinxup32.mir
10 ;test2add_32: 3 operands LEA32r that can be replaced with 2 add instructions
11 ; where ADD32ri is chosen
12 define i32 @test2add_32() {
16 ;test2add_ebp_32: 3 operands LEA32r that can be replaced with 2 add instructions
17 ; where the base is rbp/r13/ebp register
18 define i32 @test2add_ebp_32() {
22 ;test1add_ebp_32: 2 operands LEA32r where base register is ebp and can be replaced
23 ; with an add instruction
24 define i32 @test1add_ebp_32() {
28 ;testleaadd_32: 3 operands LEA32r that can be replaced with 1 lea 1 add instructions
29 define i32 @testleaadd_32() {
33 ;testleaadd_ebp_32: 3 operands LEA32r that can be replaced with 1 lea 1 add instructions
34 ; where the base is ebp register
35 define i32 @testleaadd_ebp_32() {
39 ;test1lea_ebp_32: 2 operands LEA32r wher base register is rbp/r13/ebp and can be replaced
40 ; with a lea instruction
41 define i32 @test1lea_ebp_32() {
45 ;test2addi32_32: 3 operands LEA32r that can be replaced with 2 add instructions where ADD32ri32
47 define i32 @test2addi32_32() {
51 ;test_leab_ebp_leais_32: 2 operands LEA32r that can be replaced with LEA_IS form
52 ; where the base is rbp/r13/ebp register
53 define i32 @test_leab_ebp_leais_32() {
57 ;test_leabi_ebp_leais_32: 3 operands LEA32r that can be replaced with LEA_IS form
58 ; where the base and the index are ebp register and there is offset
59 define i32 @test_leabi_ebp_leais_32() {
63 ;testleaadd_ebp_index2_32: 3 operands LEA32r that can be replaced with 1 lea 1 add instructions
64 ; where the base and the index are ebp register and there is scale
65 define i32 @testleaadd_ebp_index2_32() {
69 ;test_skip_opt_32: 3 operands LEA32r that can not be replaced with 2 instructions
70 define i32 @test_skip_opt_32() {
74 ;test_skip_eflags_32: LEA32r that cannot be replaced since its not safe to clobber eflags
75 define i32 @test_skip_eflags_32() {
83 exposesReturnsTwice: false
85 regBankSelected: false
87 tracksRegLiveness: true
92 isFrameAddressTaken: false
93 isReturnAddressTaken: false
102 hasOpaqueSPAdjustment: false
104 hasMustTailInVarArgFunc: false
109 ; CHECK-LABEL: name: test2add_32
110 ; CHECK: liveins: $eax, $ebp
111 ; CHECK: $eax = ADD32rr $eax, $ebp, implicit-def $eflags
112 ; CHECK: $eax = ADD32ri $eax, -5, implicit-def $eflags
114 $eax = LEA32r killed $eax, 1, killed $ebp, -5, $noreg
119 name: test2add_ebp_32
121 exposesReturnsTwice: false
123 regBankSelected: false
125 tracksRegLiveness: true
130 isFrameAddressTaken: false
131 isReturnAddressTaken: false
140 hasOpaqueSPAdjustment: false
142 hasMustTailInVarArgFunc: false
147 ; CHECK-LABEL: name: test2add_ebp_32
148 ; CHECK: liveins: $eax, $ebp
149 ; CHECK: $ebp = ADD32rr $ebp, $eax, implicit-def $eflags
150 ; CHECK: $ebp = ADD32ri $ebp, -5, implicit-def $eflags
152 $ebp = LEA32r killed $ebp, 1, killed $eax, -5, $noreg
157 name: test1add_ebp_32
159 exposesReturnsTwice: false
161 regBankSelected: false
163 tracksRegLiveness: true
168 isFrameAddressTaken: false
169 isReturnAddressTaken: false
178 hasOpaqueSPAdjustment: false
180 hasMustTailInVarArgFunc: false
185 ; CHECK-LABEL: name: test1add_ebp_32
186 ; CHECK: liveins: $eax, $ebp
187 ; CHECK: $ebp = ADD32rr $ebp, $eax, implicit-def $eflags
189 $ebp = LEA32r killed $ebp, 1, killed $eax, 0, $noreg
196 exposesReturnsTwice: false
198 regBankSelected: false
200 tracksRegLiveness: true
206 isFrameAddressTaken: false
207 isReturnAddressTaken: false
216 hasOpaqueSPAdjustment: false
218 hasMustTailInVarArgFunc: false
221 liveins: $eax, $ebp, $esi
223 ; CHECK-LABEL: name: testleaadd_32
224 ; CHECK: liveins: $eax, $ebp, $esi
225 ; CHECK: $ebx = LEA32r killed $eax, 1, killed $ebp, 0, $noreg
226 ; CHECK: $ebx = ADD32ri $ebx, -5, implicit-def $eflags
228 $ebx = LEA32r killed $eax, 1, killed $ebp, -5, $noreg
233 name: testleaadd_ebp_32
235 exposesReturnsTwice: false
237 regBankSelected: false
239 tracksRegLiveness: true
245 isFrameAddressTaken: false
246 isReturnAddressTaken: false
255 hasOpaqueSPAdjustment: false
257 hasMustTailInVarArgFunc: false
262 ; CHECK-LABEL: name: testleaadd_ebp_32
263 ; CHECK: liveins: $eax, $ebp
264 ; CHECK: $ebx = LEA32r killed $eax, 1, killed $ebp, 0, $noreg
265 ; CHECK: $ebx = ADD32ri $ebx, -5, implicit-def $eflags
267 $ebx = LEA32r killed $ebp, 1, killed $eax, -5, $noreg
272 name: test1lea_ebp_32
274 exposesReturnsTwice: false
276 regBankSelected: false
278 tracksRegLiveness: true
284 isFrameAddressTaken: false
285 isReturnAddressTaken: false
294 hasOpaqueSPAdjustment: false
296 hasMustTailInVarArgFunc: false
301 ; CHECK-LABEL: name: test1lea_ebp_32
302 ; CHECK: liveins: $eax, $ebp
303 ; CHECK: $ebx = LEA32r killed $eax, 1, killed $ebp, 0, $noreg
305 $ebx = LEA32r killed $ebp, 1, killed $eax, 0, $noreg
312 exposesReturnsTwice: false
314 regBankSelected: false
316 tracksRegLiveness: true
321 isFrameAddressTaken: false
322 isReturnAddressTaken: false
331 hasOpaqueSPAdjustment: false
333 hasMustTailInVarArgFunc: false
338 ; CHECK-LABEL: name: test2addi32_32
339 ; CHECK: liveins: $eax, $ebp
340 ; CHECK: $eax = ADD32rr $eax, $ebp, implicit-def $eflags
341 ; CHECK: $eax = ADD32ri $eax, 129, implicit-def $eflags
343 $eax = LEA32r killed $eax, 1, killed $ebp, 129, $noreg
348 name: test_leab_ebp_leais_32
350 exposesReturnsTwice: false
352 regBankSelected: false
354 tracksRegLiveness: true
360 isFrameAddressTaken: false
361 isReturnAddressTaken: false
370 hasOpaqueSPAdjustment: false
372 hasMustTailInVarArgFunc: false
375 liveins: $eax, $ebp, $ebx
377 ; CHECK-LABEL: name: test_leab_ebp_leais_32
378 ; CHECK: liveins: $eax, $ebp, $ebx
379 ; CHECK: $ebx = LEA32r $noreg, 2, $ebp, 0, $noreg
381 $ebx = LEA32r killed $ebp, 1, $ebp, 0, $noreg
386 name: test_leabi_ebp_leais_32
388 exposesReturnsTwice: false
390 regBankSelected: false
392 tracksRegLiveness: true
397 isFrameAddressTaken: false
398 isReturnAddressTaken: false
407 hasOpaqueSPAdjustment: false
409 hasMustTailInVarArgFunc: false
412 liveins: $eax, $ebp, $ebx
414 ; CHECK-LABEL: name: test_leabi_ebp_leais_32
415 ; CHECK: liveins: $eax, $ebp, $ebx
416 ; CHECK: $ebx = LEA32r $noreg, 2, $ebp, 5, $noreg
418 $ebx = LEA32r $ebp, 1, $ebp, 5, $noreg
423 name: testleaadd_ebp_index2_32
425 exposesReturnsTwice: false
427 regBankSelected: false
429 tracksRegLiveness: true
434 isFrameAddressTaken: false
435 isReturnAddressTaken: false
444 hasOpaqueSPAdjustment: false
446 hasMustTailInVarArgFunc: false
449 liveins: $eax, $ebp, $ebx
451 ; CHECK-LABEL: name: testleaadd_ebp_index2_32
452 ; CHECK: liveins: $eax, $ebp, $ebx
453 ; CHECK: $ebx = LEA32r $noreg, 4, $ebp, 5, $noreg
454 ; CHECK: $ebx = ADD32rr $ebx, $ebp, implicit-def $eflags
456 $ebx = LEA32r $ebp, 4, $ebp, 5, $noreg
461 name: test_skip_opt_32
463 exposesReturnsTwice: false
465 regBankSelected: false
467 tracksRegLiveness: true
472 isFrameAddressTaken: false
473 isReturnAddressTaken: false
482 hasOpaqueSPAdjustment: false
484 hasMustTailInVarArgFunc: false
487 liveins: $eax, $ebp, $ebx
489 ; CHECK-LABEL: name: test_skip_opt_32
490 ; CHECK: liveins: $eax, $ebp, $ebx
491 ; CHECK: $ebp = LEA32r killed $ebp, 4, killed $ebp, 0, $noreg
493 $ebp = LEA32r killed $ebp, 4, killed $ebp, 0, $noreg
498 name: test_skip_eflags_32
500 exposesReturnsTwice: false
502 regBankSelected: false
504 tracksRegLiveness: true
509 isFrameAddressTaken: false
510 isReturnAddressTaken: false
519 hasOpaqueSPAdjustment: false
521 hasMustTailInVarArgFunc: false
523 ; CHECK-LABEL: name: test_skip_eflags_32
524 ; CHECK: bb.0 (%ir-block.0):
525 ; CHECK: successors: %bb.1(0x80000000)
526 ; CHECK: liveins: $eax, $ebp, $ebx
527 ; CHECK: CMP32rr $eax, killed $ebx, implicit-def $eflags
528 ; CHECK: $ebx = LEA32r killed $eax, 4, killed $eax, 5, $noreg
529 ; CHECK: JCC_1 %bb.1, 4, implicit $eflags
532 ; CHECK: liveins: $eax, $ebp, $ebx
533 ; CHECK: $ebp = LEA32r killed $ebx, 4, killed $ebx, 0, $noreg
534 ; CHECK: $ebp = ADD32ri $ebp, 5, implicit-def $eflags
537 liveins: $eax, $ebp, $ebx
539 CMP32rr $eax, killed $ebx, implicit-def $eflags
540 $ebx = LEA32r killed $eax, 4, killed $eax, 5, $noreg
541 JCC_1 %bb.1, 4, implicit $eflags
544 liveins: $eax, $ebp, $ebx
545 $ebp = LEA32r killed $ebx, 4, killed $ebx, 5, $noreg