1 # RUN: llc -run-pass x86-fixup-LEAs -mtriple=x86_64-gnu-unknown -verify-machineinstrs -mcpu=corei7-avx -o - %s | FileCheck %s
3 ; ModuleID = 'lea-2.ll'
4 source_filename = "lea-2.ll"
5 target datalayout = "e-m:e-i64:64-f80:128-n8:16:32:64-S128"
6 ;generated using: llc -stop-after x86-pad-short-functions lea-2.ll > leaFinxup64.mir
8 ;testleaadd_64_32_1: 3 operands LEA64_32r cannot be replaced with 2 add instructions
9 ; but can be replaced with 1 lea + 1 add
10 define i32 @testleaadd_64_32_1() {
14 ;testleaadd_rbp_64_32_1: 3 operands LEA64_32r cannot be replaced with 2 add instructions
15 ; where the base is rbp/r13/ebp register but it can be replaced with 1 lea + 1 add
16 define i32 @testleaadd_rbp_64_32_1() {
20 ;test1lea_rbp_64_32_1: 2 operands LEA64_32r where base register is rbp/r13/ebp and can not
21 ; be replaced with an add instruction but can be replaced with 1 lea instruction
22 define i32 @test1lea_rbp_64_32_1() {
26 ;test2add_64: 3 operands LEA64r that can be replaced with 2 add instructions
27 define i32 @test2add_64() {
31 ;test2add_rbp_64: 3 operands LEA64r that can be replaced with 2 add instructions
32 ; where the base is rbp/r13/ebp register
33 define i32 @test2add_rbp_64() {
37 ;test1add_rbp_64: 2 operands LEA64r where base register is rbp/r13/ebp and can be replaced
38 ; with an add instruction
39 define i32 @test1add_rbp_64() {
43 ;testleaadd_64_32: 3 operands LEA64_32r that can be replaced with 1 lea 1 add instructions
44 define i32 @testleaadd_64_32() {
48 ;testleaadd_rbp_64_32: 3 operands LEA64_32r that can be replaced with 1 lea 1 add instructions
49 ; where the base is rbp/r13/ebp register
50 define i32 @testleaadd_rbp_64_32() {
54 ;test1lea_rbp_64_32: 2 operands LEA64_32r where base register is rbp/r13/ebp and can be replaced
55 ; with a lea instruction
56 define i32 @test1lea_rbp_64_32() {
60 ;testleaadd_64: 3 operands LEA64r that can be replaced with 1 lea 1 add instructions
61 define i32 @testleaadd_64() {
65 ;testleaadd_rbp_64: 3 operands LEA64r that can be replaced with 1 lea 1 add instructions
66 ; where the base is rbp/r13/ebp register
67 define i32 @testleaadd_rbp_64() {
71 ;test1lea_rbp_64: 2 operands LEA64r wher base register is rbp/r13/ebp and can be replaced
72 ; with a lea instruction
73 define i32 @test1lea_rbp_64() {
77 ;test8: dst = base & scale!=1, can't optimize
82 ;testleaaddi32_64_32: 3 operands LEA64_32r that can be replaced with 1 lea + 1 add instructions where
84 define i32 @testleaaddi32_64_32() {
88 ;test1mov1add_rbp_64_32: 2 operands LEA64_32r cannot be replaced with 1 add 1 mov instructions
89 ; where the base is rbp/r13/ebp register
90 define i32 @test1mov1add_rbp_64_32() {
94 ;testleaadd_rbp_index_64_32: 3 operands LEA64_32r that cannot replaced with 1 lea 1 add instructions
95 ; where the base and the index are ebp register and there is offset
96 define i32 @testleaadd_rbp_index_64_32() {
100 ;testleaadd_rbp_index2_64_32: 3 operands LEA64_32r that cannot replaced with 1 lea 1 add instructions
101 ; where the base and the index are ebp register and there is scale
102 define i32 @testleaadd_rbp_index2_64_32() {
106 ;test2addi32_64: 3 operands LEA64r that can be replaced with 2 add instructions where ADD64ri32
108 define i32 @test2addi32_64() {
112 ;test1mov1add_rbp_64: 2 operands LEA64r that can be replaced with 1 add 1 mov instructions
113 ; where the base is rbp/r13/ebp register
114 define i32 @test1mov1add_rbp_64() {
118 ;testleaadd_rbp_index_64: 3 operands LEA64r that can be replaced with 1 lea 1 add instructions
119 ; where the base and the index are ebp register and there is offset
120 define i32 @testleaadd_rbp_index_64() {
124 ;testleaadd_rbp_index2_64: 3 operands LEA64r that can be replaced with 1 lea 1 add instructions
125 ; where the base and the index are ebp register and there is scale
126 define i32 @testleaadd_rbp_index2_64() {
130 ;test_skip_opt_64: 3 operands LEA64r that can not be replaced with 2 instructions
131 define i32 @test_skip_opt_64() {
135 ;test_skip_eflags_64: LEA64r that cannot be replaced since its not safe to clobber eflags
136 define i32 @test_skip_eflags_64() {
140 ;test_skip_opt_64_32: 3 operands LEA64_32r that can not be replaced with 2 instructions
141 define i32 @test_skip_opt_64_32() {
145 ;test_skip_eflags_64_32: LEA64_32r that cannot be replaced since its not safe to clobber eflags
146 define i32 @test_skip_eflags_64_32() {
153 name: testleaadd_64_32_1
155 exposesReturnsTwice: false
157 regBankSelected: false
159 tracksRegLiveness: true
164 isFrameAddressTaken: false
165 isReturnAddressTaken: false
174 hasOpaqueSPAdjustment: false
176 hasMustTailInVarArgFunc: false
180 ; CHECK: $eax = LEA64_32r killed $rax, 1, killed $rbp, 0
181 ; CHECK: $eax = ADD32ri8 $eax, -5
183 $eax = LEA64_32r killed $rax, 1, killed $rbp, -5, $noreg
188 name: testleaadd_rbp_64_32_1
190 exposesReturnsTwice: false
192 regBankSelected: false
194 tracksRegLiveness: true
199 isFrameAddressTaken: false
200 isReturnAddressTaken: false
209 hasOpaqueSPAdjustment: false
211 hasMustTailInVarArgFunc: false
215 ; CHECK: $ebp = LEA64_32r killed $rax, 1, killed $rbp, 0
216 ; CHECK: $ebp = ADD32ri8 $ebp, -5
218 $ebp = LEA64_32r killed $rbp, 1, killed $rax, -5, $noreg
223 name: test1lea_rbp_64_32_1
225 exposesReturnsTwice: false
227 regBankSelected: false
229 tracksRegLiveness: true
234 isFrameAddressTaken: false
235 isReturnAddressTaken: false
244 hasOpaqueSPAdjustment: false
246 hasMustTailInVarArgFunc: false
250 ; CHECK: $ebp = ADD32rr $ebp, $eax, implicit-def $eflags, implicit $rbp, implicit $rax
252 $ebp = LEA64_32r killed $rbp, 1, killed $rax, 0, $noreg
259 exposesReturnsTwice: false
261 regBankSelected: false
263 tracksRegLiveness: true
268 isFrameAddressTaken: false
269 isReturnAddressTaken: false
278 hasOpaqueSPAdjustment: false
280 hasMustTailInVarArgFunc: false
284 ; CHECK: $rax = ADD64rr $rax, killed $rbp
285 ; CHECK: $rax = ADD64ri8 $rax, -5
287 $rax = LEA64r killed $rax, 1, killed $rbp, -5, $noreg
292 name: test2add_rbp_64
294 exposesReturnsTwice: false
296 regBankSelected: false
298 tracksRegLiveness: true
303 isFrameAddressTaken: false
304 isReturnAddressTaken: false
313 hasOpaqueSPAdjustment: false
315 hasMustTailInVarArgFunc: false
319 ; CHECK: $rbp = ADD64rr $rbp, killed $rax
320 ; CHECK: $rbp = ADD64ri8 $rbp, -5
322 $rbp = LEA64r killed $rbp, 1, killed $rax, -5, $noreg
327 name: test1add_rbp_64
329 exposesReturnsTwice: false
331 regBankSelected: false
333 tracksRegLiveness: true
338 isFrameAddressTaken: false
339 isReturnAddressTaken: false
348 hasOpaqueSPAdjustment: false
350 hasMustTailInVarArgFunc: false
354 ; CHECK: $rbp = ADD64rr $rbp, $rax
356 $rbp = LEA64r killed $rbp, 1, killed $rax, 0, $noreg
361 name: testleaadd_64_32
363 exposesReturnsTwice: false
365 regBankSelected: false
367 tracksRegLiveness: true
373 isFrameAddressTaken: false
374 isReturnAddressTaken: false
383 hasOpaqueSPAdjustment: false
385 hasMustTailInVarArgFunc: false
389 ; CHECK: $ebx = LEA64_32r killed $rax, 1, killed $rbp, 0, $noreg
390 ; CHECK: $ebx = ADD32ri8 $ebx, -5
392 $ebx = LEA64_32r killed $rax, 1, killed $rbp, -5, $noreg
397 name: testleaadd_rbp_64_32
399 exposesReturnsTwice: false
401 regBankSelected: false
403 tracksRegLiveness: true
409 isFrameAddressTaken: false
410 isReturnAddressTaken: false
419 hasOpaqueSPAdjustment: false
421 hasMustTailInVarArgFunc: false
425 ; CHECK: $ebx = LEA64_32r killed $rax, 1, killed $rbp, 0, $noreg
426 ; CHECK: $ebx = ADD32ri8 $ebx, -5
428 $ebx = LEA64_32r killed $rbp, 1, killed $rax, -5, $noreg
433 name: test1lea_rbp_64_32
435 exposesReturnsTwice: false
437 regBankSelected: false
439 tracksRegLiveness: true
445 isFrameAddressTaken: false
446 isReturnAddressTaken: false
455 hasOpaqueSPAdjustment: false
457 hasMustTailInVarArgFunc: false
461 ; CHECK: $ebx = LEA64_32r killed $rax, 1, killed $rbp, 0, $noreg
463 $ebx = LEA64_32r killed $rbp, 1, killed $rax, 0, $noreg
470 exposesReturnsTwice: false
472 regBankSelected: false
474 tracksRegLiveness: true
480 isFrameAddressTaken: false
481 isReturnAddressTaken: false
490 hasOpaqueSPAdjustment: false
492 hasMustTailInVarArgFunc: false
496 ; CHECK: $rbx = LEA64r killed $rax, 1, killed $rbp, 0, $noreg
497 ; CHECK: $rbx = ADD64ri8 $rbx, -5
499 $rbx = LEA64r killed $rax, 1, killed $rbp, -5, $noreg
504 name: testleaadd_rbp_64
506 exposesReturnsTwice: false
508 regBankSelected: false
510 tracksRegLiveness: true
516 isFrameAddressTaken: false
517 isReturnAddressTaken: false
526 hasOpaqueSPAdjustment: false
528 hasMustTailInVarArgFunc: false
532 ; CHECK: $rbx = LEA64r killed $rax, 1, killed $rbp, 0, $noreg
533 ; CHECK: $rbx = ADD64ri8 $rbx, -5
535 $rbx = LEA64r killed $rbp, 1, killed $rax, -5, $noreg
540 name: test1lea_rbp_64
542 exposesReturnsTwice: false
544 regBankSelected: false
546 tracksRegLiveness: true
552 isFrameAddressTaken: false
553 isReturnAddressTaken: false
562 hasOpaqueSPAdjustment: false
564 hasMustTailInVarArgFunc: false
568 ; CHECK: $rbx = LEA64r killed $rax, 1, killed $rbp, 0, $noreg
570 $rbx = LEA64r killed $rbp, 1, killed $rax, 0, $noreg
577 exposesReturnsTwice: false
579 regBankSelected: false
581 tracksRegLiveness: true
586 isFrameAddressTaken: false
587 isReturnAddressTaken: false
596 hasOpaqueSPAdjustment: false
598 hasMustTailInVarArgFunc: false
602 ; CHECK: $r12 = LEA64r $noreg, 2, killed $r13, 5, $noreg
603 ; CHECK: $r12 = ADD64rr $r12, killed $rbp
604 $rbp = KILL $rbp, implicit-def $rbp
605 $r13 = KILL $rdi, implicit-def $r13
606 $r12 = LEA64r killed $rbp, 2, killed $r13, 5, $noreg
611 name: testleaaddi32_64_32
613 exposesReturnsTwice: false
615 regBankSelected: false
617 tracksRegLiveness: true
622 isFrameAddressTaken: false
623 isReturnAddressTaken: false
632 hasOpaqueSPAdjustment: false
634 hasMustTailInVarArgFunc: false
638 ; CHECK: $eax = LEA64_32r killed $rax, 1, killed $rbp, 0
639 ; CHECK: $eax = ADD32ri $eax, 129
641 $eax = LEA64_32r killed $rax, 1, killed $rbp, 129, $noreg
646 name: test1mov1add_rbp_64_32
648 exposesReturnsTwice: false
650 regBankSelected: false
652 tracksRegLiveness: true
657 isFrameAddressTaken: false
658 isReturnAddressTaken: false
667 hasOpaqueSPAdjustment: false
669 hasMustTailInVarArgFunc: false
672 liveins: $rax, $rbp, $rbx
673 ; CHECK: $ebx = LEA64_32r killed $rbp, 1, killed $rbp, 0, $noreg
675 $ebx = LEA64_32r killed $rbp, 1, killed $rbp, 0, $noreg
680 name: testleaadd_rbp_index_64_32
682 exposesReturnsTwice: false
684 regBankSelected: false
686 tracksRegLiveness: true
691 isFrameAddressTaken: false
692 isReturnAddressTaken: false
701 hasOpaqueSPAdjustment: false
703 hasMustTailInVarArgFunc: false
706 liveins: $rax, $rbp, $rbx
707 ; CHECK: $ebx = LEA64_32r killed $rbp, 1, killed $rbp, 5, $noreg
709 $ebx = LEA64_32r killed $rbp, 1, killed $rbp, 5, $noreg
714 name: testleaadd_rbp_index2_64_32
716 exposesReturnsTwice: false
718 regBankSelected: false
720 tracksRegLiveness: true
725 isFrameAddressTaken: false
726 isReturnAddressTaken: false
735 hasOpaqueSPAdjustment: false
737 hasMustTailInVarArgFunc: false
740 liveins: $eax, $ebp, $ebx
741 ; CHECK: $ebx = LEA64_32r killed $rbp, 4, killed $rbp, 5, $noreg
743 $ebx = LEA64_32r killed $rbp, 4, killed $rbp, 5, $noreg
750 exposesReturnsTwice: false
752 regBankSelected: false
754 tracksRegLiveness: true
759 isFrameAddressTaken: false
760 isReturnAddressTaken: false
769 hasOpaqueSPAdjustment: false
771 hasMustTailInVarArgFunc: false
775 ; CHECK: $rax = ADD64rr $rax, killed $rbp
776 ; CHECK: $rax = ADD64ri32 $rax, 129
778 $rax = LEA64r killed $rax, 1, killed $rbp, 129, $noreg
783 name: test1mov1add_rbp_64
785 exposesReturnsTwice: false
787 regBankSelected: false
789 tracksRegLiveness: true
794 isFrameAddressTaken: false
795 isReturnAddressTaken: false
804 hasOpaqueSPAdjustment: false
806 hasMustTailInVarArgFunc: false
809 liveins: $rax, $rbp, $rbx
810 ; CHECK: $rbx = MOV64rr $rbp
811 ; CHECK: $rbx = ADD64rr $rbx, $rbp
813 $rbx = LEA64r killed $rbp, 1, $rbp, 0, $noreg
818 name: testleaadd_rbp_index_64
820 exposesReturnsTwice: false
822 regBankSelected: false
824 tracksRegLiveness: true
829 isFrameAddressTaken: false
830 isReturnAddressTaken: false
839 hasOpaqueSPAdjustment: false
841 hasMustTailInVarArgFunc: false
844 liveins: $rax, $rbp, $rbx
845 ; CHECK: $rbx = LEA64r $noreg, 1, $rbp, 5, $noreg
846 ; CHECK: $rbx = ADD64rr $rbx, $rbp
848 $rbx = LEA64r $rbp, 1, $rbp, 5, $noreg
853 name: testleaadd_rbp_index2_64
855 exposesReturnsTwice: false
857 regBankSelected: false
859 tracksRegLiveness: true
864 isFrameAddressTaken: false
865 isReturnAddressTaken: false
874 hasOpaqueSPAdjustment: false
876 hasMustTailInVarArgFunc: false
879 liveins: $rax, $rbp, $rbx
880 ; CHECK: $rbx = LEA64r $noreg, 4, $rbp, 5, $noreg
881 ; CHECK: $rbx = ADD64rr $rbx, $rbp
883 $rbx = LEA64r $rbp, 4, $rbp, 5, $noreg
888 name: test_skip_opt_64
890 exposesReturnsTwice: false
892 regBankSelected: false
894 tracksRegLiveness: true
899 isFrameAddressTaken: false
900 isReturnAddressTaken: false
909 hasOpaqueSPAdjustment: false
911 hasMustTailInVarArgFunc: false
914 liveins: $rax, $rbp, $rbx
915 ; CHECK: $rbp = LEA64r killed $rbp, 4, killed $rbp, 0, $noreg
917 $rbp = LEA64r killed $rbp, 4, killed $rbp, 0, $noreg
922 name: test_skip_eflags_64
924 exposesReturnsTwice: false
926 regBankSelected: false
928 tracksRegLiveness: true
933 isFrameAddressTaken: false
934 isReturnAddressTaken: false
943 hasOpaqueSPAdjustment: false
945 hasMustTailInVarArgFunc: false
948 liveins: $rax, $rbp, $rbx
949 ; CHECK: $rbx = LEA64r killed $rax, 4, killed $rax, 5, $noreg
950 ; CHECK: $rbp = LEA64r killed $rbx, 4, killed $rbx, 0, $noreg
951 ; CHECK: $rbp = ADD64ri8 $rbp, 5
953 CMP64rr $rax, killed $rbx, implicit-def $eflags
954 $rbx = LEA64r killed $rax, 4, killed $rax, 5, $noreg
955 JCC_1 %bb.1, 4, implicit $eflags
958 liveins: $rax, $rbp, $rbx
959 $rbp = LEA64r killed $rbx, 4, killed $rbx, 5, $noreg
964 name: test_skip_opt_64_32
966 exposesReturnsTwice: false
968 regBankSelected: false
970 tracksRegLiveness: true
975 isFrameAddressTaken: false
976 isReturnAddressTaken: false
985 hasOpaqueSPAdjustment: false
987 hasMustTailInVarArgFunc: false
990 liveins: $rax, $rbp, $rbx
991 ; CHECK: $ebp = LEA64_32r killed $rbp, 4, killed $rbp, 0, $noreg
993 $ebp = LEA64_32r killed $rbp, 4, killed $rbp, 0, $noreg
998 name: test_skip_eflags_64_32
1000 exposesReturnsTwice: false
1002 regBankSelected: false
1004 tracksRegLiveness: true
1009 isFrameAddressTaken: false
1010 isReturnAddressTaken: false
1012 hasPatchPoint: false
1019 hasOpaqueSPAdjustment: false
1021 hasMustTailInVarArgFunc: false
1024 liveins: $rax, $rbp, $rbx
1025 ; CHECK: $ebx = LEA64_32r killed $rax, 4, killed $rax, 5, $noreg
1026 ; CHECK: $ebp = LEA64_32r killed $rbx, 4, killed $rbx, 0, $noreg
1027 ; CHECK: $ebp = ADD32ri8 $ebp, 5
1029 CMP64rr $rax, killed $rbx, implicit-def $eflags
1030 $ebx = LEA64_32r killed $rax, 4, killed $rax, 5, $noreg
1031 JCC_1 %bb.1, 4, implicit $eflags
1034 liveins: $rax, $rbp, $rbx
1035 $ebp = LEA64_32r killed $rbx, 4, killed $rbx, 5, $noreg