1 # RUN: llc -run-pass x86-fixup-LEAs -mtriple=i386 -verify-machineinstrs -mcpu=corei7-avx -o - %s | FileCheck %s
3 ; ModuleID = 'test/CodeGen/X86/fixup-lea.ll'
4 source_filename = "test/CodeGen/X86/fixup-lea.ll"
5 target datalayout = "e-m:e-p:32:32-f64:32:64-f80:32-n8:16:32-S128"
7 ;generated using: llc -stop-after x86-pad-short-functions fixup-lea.ll > leaFinxup32.mir
9 ;test2add_32: 3 operands LEA32r that can be replaced with 2 add instructions
10 ; where ADD32ri8 is chosen
11 define i32 @test2add_32() {
15 ;test2add_ebp_32: 3 operands LEA32r that can be replaced with 2 add instructions
16 ; where the base is rbp/r13/ebp register
17 define i32 @test2add_ebp_32() {
21 ;test1add_ebp_32: 2 operands LEA32r where base register is ebp and can be replaced
22 ; with an add instruction
23 define i32 @test1add_ebp_32() {
27 ;testleaadd_32: 3 operands LEA32r that can be replaced with 1 lea 1 add instructions
28 define i32 @testleaadd_32() {
32 ;testleaadd_ebp_32: 3 operands LEA32r that can be replaced with 1 lea 1 add instructions
33 ; where the base is ebp register
34 define i32 @testleaadd_ebp_32() {
38 ;test1lea_ebp_32: 2 operands LEA32r wher base register is rbp/r13/ebp and can be replaced
39 ; with a lea instruction
40 define i32 @test1lea_ebp_32() {
44 ;test2addi32_32: 3 operands LEA32r that can be replaced with 2 add instructions where ADD32ri32
46 define i32 @test2addi32_32() {
50 ;test1mov1add_ebp_32: 2 operands LEA32r that can be replaced with 1 add 1 mov instructions
51 ; where the base is rbp/r13/ebp register
52 define i32 @test1mov1add_ebp_32() {
56 ;testleaadd_ebp_index_32: 3 operands LEA32r that can be replaced with 1 lea 1 add instructions
57 ; where the base and the index are ebp register and there is offset
58 define i32 @testleaadd_ebp_index_32() {
62 ;testleaadd_ebp_index2_32: 3 operands LEA32r that can be replaced with 1 lea 1 add instructions
63 ; where the base and the index are ebp register and there is scale
64 define i32 @testleaadd_ebp_index2_32() {
68 ;test_skip_opt_32: 3 operands LEA32r that can not be replaced with 2 instructions
69 define i32 @test_skip_opt_32() {
73 ;test_skip_eflags_32: LEA32r that cannot be replaced since its not safe to clobber eflags
74 define i32 @test_skip_eflags_32() {
82 exposesReturnsTwice: false
84 regBankSelected: false
86 tracksRegLiveness: true
91 isFrameAddressTaken: false
92 isReturnAddressTaken: false
101 hasOpaqueSPAdjustment: false
103 hasMustTailInVarArgFunc: false
107 ; CHECK: $eax = ADD32rr $eax, killed $ebp
108 ; CHECK: $eax = ADD32ri8 $eax, -5
110 $eax = LEA32r killed $eax, 1, killed $ebp, -5, $noreg
115 name: test2add_ebp_32
117 exposesReturnsTwice: false
119 regBankSelected: false
121 tracksRegLiveness: true
126 isFrameAddressTaken: false
127 isReturnAddressTaken: false
136 hasOpaqueSPAdjustment: false
138 hasMustTailInVarArgFunc: false
142 ; CHECK: $ebp = ADD32rr $ebp, killed $eax
143 ; CHECK: $ebp = ADD32ri8 $ebp, -5
145 $ebp = LEA32r killed $ebp, 1, killed $eax, -5, $noreg
150 name: test1add_ebp_32
152 exposesReturnsTwice: false
154 regBankSelected: false
156 tracksRegLiveness: true
161 isFrameAddressTaken: false
162 isReturnAddressTaken: false
171 hasOpaqueSPAdjustment: false
173 hasMustTailInVarArgFunc: false
177 ; CHECK: $ebp = ADD32rr $ebp, $eax
179 $ebp = LEA32r killed $ebp, 1, killed $eax, 0, $noreg
186 exposesReturnsTwice: false
188 regBankSelected: false
190 tracksRegLiveness: true
196 isFrameAddressTaken: false
197 isReturnAddressTaken: false
206 hasOpaqueSPAdjustment: false
208 hasMustTailInVarArgFunc: false
211 liveins: $eax, $ebp, $esi
212 ; CHECK: $ebx = LEA32r killed $eax, 1, killed $ebp, 0
213 ; CHECK: $ebx = ADD32ri8 $ebx, -5
215 $ebx = LEA32r killed $eax, 1, killed $ebp, -5, $noreg
220 name: testleaadd_ebp_32
222 exposesReturnsTwice: false
224 regBankSelected: false
226 tracksRegLiveness: true
232 isFrameAddressTaken: false
233 isReturnAddressTaken: false
242 hasOpaqueSPAdjustment: false
244 hasMustTailInVarArgFunc: false
248 ; CHECK: $ebx = LEA32r killed $eax, 1, killed $ebp, 0, $noreg
249 ; CHECK: $ebx = ADD32ri8 $ebx, -5
251 $ebx = LEA32r killed $ebp, 1, killed $eax, -5, $noreg
256 name: test1lea_ebp_32
258 exposesReturnsTwice: false
260 regBankSelected: false
262 tracksRegLiveness: true
268 isFrameAddressTaken: false
269 isReturnAddressTaken: false
278 hasOpaqueSPAdjustment: false
280 hasMustTailInVarArgFunc: false
284 ; CHECK: $ebx = LEA32r killed $eax, 1, killed $ebp, 0, $noreg
286 $ebx = LEA32r killed $ebp, 1, killed $eax, 0, $noreg
293 exposesReturnsTwice: false
295 regBankSelected: false
297 tracksRegLiveness: true
302 isFrameAddressTaken: false
303 isReturnAddressTaken: false
312 hasOpaqueSPAdjustment: false
314 hasMustTailInVarArgFunc: false
318 ; CHECK: $eax = ADD32rr $eax, killed $ebp
319 ; CHECK: $eax = ADD32ri $eax, 129
321 $eax = LEA32r killed $eax, 1, killed $ebp, 129, $noreg
326 name: test1mov1add_ebp_32
328 exposesReturnsTwice: false
330 regBankSelected: false
332 tracksRegLiveness: true
338 isFrameAddressTaken: false
339 isReturnAddressTaken: false
348 hasOpaqueSPAdjustment: false
350 hasMustTailInVarArgFunc: false
353 liveins: $eax, $ebp, $ebx
354 ; CHECK: $ebx = MOV32rr $ebp
355 ; CHECK: $ebx = ADD32rr $ebx, $ebp
357 $ebx = LEA32r killed $ebp, 1, $ebp, 0, $noreg
362 name: testleaadd_ebp_index_32
364 exposesReturnsTwice: false
366 regBankSelected: false
368 tracksRegLiveness: true
373 isFrameAddressTaken: false
374 isReturnAddressTaken: false
383 hasOpaqueSPAdjustment: false
385 hasMustTailInVarArgFunc: false
388 liveins: $eax, $ebp, $ebx
389 ; CHECK: $ebx = LEA32r $noreg, 1, $ebp, 5, $noreg
390 ; CHECK: $ebx = ADD32rr $ebx, $ebp
392 $ebx = LEA32r $ebp, 1, $ebp, 5, $noreg
397 name: testleaadd_ebp_index2_32
399 exposesReturnsTwice: false
401 regBankSelected: false
403 tracksRegLiveness: true
408 isFrameAddressTaken: false
409 isReturnAddressTaken: false
418 hasOpaqueSPAdjustment: false
420 hasMustTailInVarArgFunc: false
423 liveins: $eax, $ebp, $ebx
424 ; CHECK: $ebx = LEA32r $noreg, 4, $ebp, 5, $noreg
425 ; CHECK: $ebx = ADD32rr $ebx, $ebp
427 $ebx = LEA32r $ebp, 4, $ebp, 5, $noreg
432 name: test_skip_opt_32
434 exposesReturnsTwice: false
436 regBankSelected: false
438 tracksRegLiveness: true
443 isFrameAddressTaken: false
444 isReturnAddressTaken: false
453 hasOpaqueSPAdjustment: false
455 hasMustTailInVarArgFunc: false
458 liveins: $eax, $ebp, $ebx
459 ; CHECK: $ebp = LEA32r killed $ebp, 4, killed $ebp, 0, $noreg
461 $ebp = LEA32r killed $ebp, 4, killed $ebp, 0, $noreg
466 name: test_skip_eflags_32
468 exposesReturnsTwice: false
470 regBankSelected: false
472 tracksRegLiveness: true
477 isFrameAddressTaken: false
478 isReturnAddressTaken: false
487 hasOpaqueSPAdjustment: false
489 hasMustTailInVarArgFunc: false
492 liveins: $eax, $ebp, $ebx
493 ; CHECK: $ebx = LEA32r killed $eax, 4, killed $eax, 5, $noreg
494 ; CHECK: $ebp = LEA32r killed $ebx, 4, killed $ebx, 0, $noreg
495 ; CHECK: $ebp = ADD32ri8 $ebp, 5
497 CMP32rr $eax, killed $ebx, implicit-def $eflags
498 $ebx = LEA32r killed $eax, 4, killed $eax, 5, $noreg
499 JCC_1 %bb.1, 4, implicit $eflags
502 liveins: $eax, $ebp, $ebx
503 $ebp = LEA32r killed $ebx, 4, killed $ebx, 5, $noreg