1# RUN: llc -run-pass x86-fixup-LEAs -mtriple=i386 -verify-machineinstrs -mcpu=corei7-avx -o - %s | FileCheck %s 2--- | 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" 6 target triple = "i386" 7 ;generated using: llc -stop-after x86-pad-short-functions fixup-lea.ll > leaFinxup32.mir 8 9 ;test2add_32: 3 operands LEA32r that can be replaced with 2 add instructions 10 ; where ADD32ri8 is chosen 11 define i32 @test2add_32() { 12 ret i32 0 13 } 14 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() { 18 ret i32 0 19 } 20 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() { 24 ret i32 0 25 } 26 27 ;testleaadd_32: 3 operands LEA32r that can be replaced with 1 lea 1 add instructions 28 define i32 @testleaadd_32() { 29 ret i32 0 30 } 31 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() { 35 ret i32 0 36 } 37 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() { 41 ret i32 0 42 } 43 44 ;test2addi32_32: 3 operands LEA32r that can be replaced with 2 add instructions where ADD32ri32 45 ; is chosen 46 define i32 @test2addi32_32() { 47 ret i32 0 48 } 49 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() { 53 ret i32 0 54 } 55 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() { 59 ret i32 0 60 } 61 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() { 65 ret i32 0 66 } 67 68 ;test_skip_opt_32: 3 operands LEA32r that can not be replaced with 2 instructions 69 define i32 @test_skip_opt_32() { 70 ret i32 0 71 } 72 73 ;test_skip_eflags_32: LEA32r that cannot be replaced since its not safe to clobber eflags 74 define i32 @test_skip_eflags_32() { 75 ret i32 0 76 } 77 78... 79--- 80name: test2add_32 81alignment: 4 82exposesReturnsTwice: false 83legalized: false 84regBankSelected: false 85selected: false 86tracksRegLiveness: true 87liveins: 88 - { reg: '$eax' } 89 - { reg: '$ebp' } 90frameInfo: 91 isFrameAddressTaken: false 92 isReturnAddressTaken: false 93 hasStackMap: false 94 hasPatchPoint: false 95 stackSize: 0 96 offsetAdjustment: 0 97 maxAlignment: 0 98 adjustsStack: false 99 hasCalls: false 100 maxCallFrameSize: 0 101 hasOpaqueSPAdjustment: false 102 hasVAStart: false 103 hasMustTailInVarArgFunc: false 104body: | 105 bb.0 (%ir-block.0): 106 liveins: $eax, $ebp 107 ; CHECK: $eax = ADD32rr $eax, killed $ebp 108 ; CHECK: $eax = ADD32ri8 $eax, -5 109 110 $eax = LEA32r killed $eax, 1, killed $ebp, -5, $noreg 111 RETQ $eax 112 113... 114--- 115name: test2add_ebp_32 116alignment: 4 117exposesReturnsTwice: false 118legalized: false 119regBankSelected: false 120selected: false 121tracksRegLiveness: true 122liveins: 123 - { reg: '$eax' } 124 - { reg: '$ebp' } 125frameInfo: 126 isFrameAddressTaken: false 127 isReturnAddressTaken: false 128 hasStackMap: false 129 hasPatchPoint: false 130 stackSize: 0 131 offsetAdjustment: 0 132 maxAlignment: 0 133 adjustsStack: false 134 hasCalls: false 135 maxCallFrameSize: 0 136 hasOpaqueSPAdjustment: false 137 hasVAStart: false 138 hasMustTailInVarArgFunc: false 139body: | 140 bb.0 (%ir-block.0): 141 liveins: $eax, $ebp 142 ; CHECK: $ebp = ADD32rr $ebp, killed $eax 143 ; CHECK: $ebp = ADD32ri8 $ebp, -5 144 145 $ebp = LEA32r killed $ebp, 1, killed $eax, -5, $noreg 146 RETQ $ebp 147 148... 149--- 150name: test1add_ebp_32 151alignment: 4 152exposesReturnsTwice: false 153legalized: false 154regBankSelected: false 155selected: false 156tracksRegLiveness: true 157liveins: 158 - { reg: '$eax' } 159 - { reg: '$ebp' } 160frameInfo: 161 isFrameAddressTaken: false 162 isReturnAddressTaken: false 163 hasStackMap: false 164 hasPatchPoint: false 165 stackSize: 0 166 offsetAdjustment: 0 167 maxAlignment: 0 168 adjustsStack: false 169 hasCalls: false 170 maxCallFrameSize: 0 171 hasOpaqueSPAdjustment: false 172 hasVAStart: false 173 hasMustTailInVarArgFunc: false 174body: | 175 bb.0 (%ir-block.0): 176 liveins: $eax, $ebp 177 ; CHECK: $ebp = ADD32rr $ebp, killed $eax 178 179 $ebp = LEA32r killed $ebp, 1, killed $eax, 0, $noreg 180 RETQ $ebp 181 182... 183--- 184name: testleaadd_32 185alignment: 4 186exposesReturnsTwice: false 187legalized: false 188regBankSelected: false 189selected: false 190tracksRegLiveness: true 191liveins: 192 - { reg: '$eax' } 193 - { reg: '$ebp' } 194 - { reg: '$ebx' } 195frameInfo: 196 isFrameAddressTaken: false 197 isReturnAddressTaken: false 198 hasStackMap: false 199 hasPatchPoint: false 200 stackSize: 0 201 offsetAdjustment: 0 202 maxAlignment: 0 203 adjustsStack: false 204 hasCalls: false 205 maxCallFrameSize: 0 206 hasOpaqueSPAdjustment: false 207 hasVAStart: false 208 hasMustTailInVarArgFunc: false 209body: | 210 bb.0 (%ir-block.0): 211 liveins: $eax, $ebp, $esi 212 ; CHECK: $ebx = LEA32r killed $eax, 1, killed $ebp, 0 213 ; CHECK: $ebx = ADD32ri8 $ebx, -5 214 215 $ebx = LEA32r killed $eax, 1, killed $ebp, -5, $noreg 216 RETQ $ebx 217 218... 219--- 220name: testleaadd_ebp_32 221alignment: 4 222exposesReturnsTwice: false 223legalized: false 224regBankSelected: false 225selected: false 226tracksRegLiveness: true 227liveins: 228 - { reg: '$eax' } 229 - { reg: '$ebp' } 230 - { reg: '$ebx' } 231frameInfo: 232 isFrameAddressTaken: false 233 isReturnAddressTaken: false 234 hasStackMap: false 235 hasPatchPoint: false 236 stackSize: 0 237 offsetAdjustment: 0 238 maxAlignment: 0 239 adjustsStack: false 240 hasCalls: false 241 maxCallFrameSize: 0 242 hasOpaqueSPAdjustment: false 243 hasVAStart: false 244 hasMustTailInVarArgFunc: false 245body: | 246 bb.0 (%ir-block.0): 247 liveins: $eax, $ebp 248 ; CHECK: $ebx = LEA32r killed $eax, 1, killed $ebp, 0, $noreg 249 ; CHECK: $ebx = ADD32ri8 $ebx, -5 250 251 $ebx = LEA32r killed $ebp, 1, killed $eax, -5, $noreg 252 RETQ $ebx 253 254... 255--- 256name: test1lea_ebp_32 257alignment: 4 258exposesReturnsTwice: false 259legalized: false 260regBankSelected: false 261selected: false 262tracksRegLiveness: true 263liveins: 264 - { reg: '$eax' } 265 - { reg: '$ebp' } 266 - { reg: '$ebx' } 267frameInfo: 268 isFrameAddressTaken: false 269 isReturnAddressTaken: false 270 hasStackMap: false 271 hasPatchPoint: false 272 stackSize: 0 273 offsetAdjustment: 0 274 maxAlignment: 0 275 adjustsStack: false 276 hasCalls: false 277 maxCallFrameSize: 0 278 hasOpaqueSPAdjustment: false 279 hasVAStart: false 280 hasMustTailInVarArgFunc: false 281body: | 282 bb.0 (%ir-block.0): 283 liveins: $eax, $ebp 284 ; CHECK: $ebx = LEA32r killed $eax, 1, killed $ebp, 0, $noreg 285 286 $ebx = LEA32r killed $ebp, 1, killed $eax, 0, $noreg 287 RETQ $ebx 288 289... 290--- 291name: test2addi32_32 292alignment: 4 293exposesReturnsTwice: false 294legalized: false 295regBankSelected: false 296selected: false 297tracksRegLiveness: true 298liveins: 299 - { reg: '$eax' } 300 - { reg: '$ebp' } 301frameInfo: 302 isFrameAddressTaken: false 303 isReturnAddressTaken: false 304 hasStackMap: false 305 hasPatchPoint: false 306 stackSize: 0 307 offsetAdjustment: 0 308 maxAlignment: 0 309 adjustsStack: false 310 hasCalls: false 311 maxCallFrameSize: 0 312 hasOpaqueSPAdjustment: false 313 hasVAStart: false 314 hasMustTailInVarArgFunc: false 315body: | 316 bb.0 (%ir-block.0): 317 liveins: $eax, $ebp 318 ; CHECK: $eax = ADD32rr $eax, killed $ebp 319 ; CHECK: $eax = ADD32ri $eax, 129 320 321 $eax = LEA32r killed $eax, 1, killed $ebp, 129, $noreg 322 RETQ $eax 323 324... 325--- 326name: test1mov1add_ebp_32 327alignment: 4 328exposesReturnsTwice: false 329legalized: false 330regBankSelected: false 331selected: false 332tracksRegLiveness: true 333liveins: 334 - { reg: '$eax' } 335 - { reg: '$ebx' } 336 - { reg: '$ebp' } 337frameInfo: 338 isFrameAddressTaken: false 339 isReturnAddressTaken: false 340 hasStackMap: false 341 hasPatchPoint: false 342 stackSize: 0 343 offsetAdjustment: 0 344 maxAlignment: 0 345 adjustsStack: false 346 hasCalls: false 347 maxCallFrameSize: 0 348 hasOpaqueSPAdjustment: false 349 hasVAStart: false 350 hasMustTailInVarArgFunc: false 351body: | 352 bb.0 (%ir-block.0): 353 liveins: $eax, $ebp, $ebx 354 ; CHECK: $ebx = MOV32rr $ebp 355 ; CHECK: $ebx = ADD32rr $ebx, $ebp 356 357 $ebx = LEA32r killed $ebp, 1, $ebp, 0, $noreg 358 RETQ $ebx 359 360... 361--- 362name: testleaadd_ebp_index_32 363alignment: 4 364exposesReturnsTwice: false 365legalized: false 366regBankSelected: false 367selected: false 368tracksRegLiveness: true 369liveins: 370 - { reg: '$ebx' } 371 - { reg: '$ebp' } 372frameInfo: 373 isFrameAddressTaken: false 374 isReturnAddressTaken: false 375 hasStackMap: false 376 hasPatchPoint: false 377 stackSize: 0 378 offsetAdjustment: 0 379 maxAlignment: 0 380 adjustsStack: false 381 hasCalls: false 382 maxCallFrameSize: 0 383 hasOpaqueSPAdjustment: false 384 hasVAStart: false 385 hasMustTailInVarArgFunc: false 386body: | 387 bb.0 (%ir-block.0): 388 liveins: $eax, $ebp, $ebx 389 ; CHECK: $ebx = LEA32r $noreg, 1, $ebp, 5, $noreg 390 ; CHECK: $ebx = ADD32rr $ebx, $ebp 391 392 $ebx = LEA32r $ebp, 1, $ebp, 5, $noreg 393 RETQ $ebx 394 395... 396--- 397name: testleaadd_ebp_index2_32 398alignment: 4 399exposesReturnsTwice: false 400legalized: false 401regBankSelected: false 402selected: false 403tracksRegLiveness: true 404liveins: 405 - { reg: '$ebx' } 406 - { reg: '$ebp' } 407frameInfo: 408 isFrameAddressTaken: false 409 isReturnAddressTaken: false 410 hasStackMap: false 411 hasPatchPoint: false 412 stackSize: 0 413 offsetAdjustment: 0 414 maxAlignment: 0 415 adjustsStack: false 416 hasCalls: false 417 maxCallFrameSize: 0 418 hasOpaqueSPAdjustment: false 419 hasVAStart: false 420 hasMustTailInVarArgFunc: false 421body: | 422 bb.0 (%ir-block.0): 423 liveins: $eax, $ebp, $ebx 424 ; CHECK: $ebx = LEA32r $noreg, 4, $ebp, 5, $noreg 425 ; CHECK: $ebx = ADD32rr $ebx, $ebp 426 427 $ebx = LEA32r $ebp, 4, $ebp, 5, $noreg 428 RETQ $ebx 429 430... 431--- 432name: test_skip_opt_32 433alignment: 4 434exposesReturnsTwice: false 435legalized: false 436regBankSelected: false 437selected: false 438tracksRegLiveness: true 439liveins: 440 - { reg: '$ebx' } 441 - { reg: '$ebp' } 442frameInfo: 443 isFrameAddressTaken: false 444 isReturnAddressTaken: false 445 hasStackMap: false 446 hasPatchPoint: false 447 stackSize: 0 448 offsetAdjustment: 0 449 maxAlignment: 0 450 adjustsStack: false 451 hasCalls: false 452 maxCallFrameSize: 0 453 hasOpaqueSPAdjustment: false 454 hasVAStart: false 455 hasMustTailInVarArgFunc: false 456body: | 457 bb.0 (%ir-block.0): 458 liveins: $eax, $ebp, $ebx 459 ; CHECK: $ebp = LEA32r killed $ebp, 4, killed $ebp, 0, $noreg 460 461 $ebp = LEA32r killed $ebp, 4, killed $ebp, 0, $noreg 462 RETQ $ebp 463 464... 465--- 466name: test_skip_eflags_32 467alignment: 4 468exposesReturnsTwice: false 469legalized: false 470regBankSelected: false 471selected: false 472tracksRegLiveness: true 473liveins: 474 - { reg: '$ebp' } 475 - { reg: '$eax' } 476frameInfo: 477 isFrameAddressTaken: false 478 isReturnAddressTaken: false 479 hasStackMap: false 480 hasPatchPoint: false 481 stackSize: 0 482 offsetAdjustment: 0 483 maxAlignment: 0 484 adjustsStack: false 485 hasCalls: false 486 maxCallFrameSize: 0 487 hasOpaqueSPAdjustment: false 488 hasVAStart: false 489 hasMustTailInVarArgFunc: false 490body: | 491 bb.0 (%ir-block.0): 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 496 497 CMP32rr $eax, killed $ebx, implicit-def $eflags 498 $ebx = LEA32r killed $eax, 4, killed $eax, 5, $noreg 499 JE_1 %bb.1, implicit $eflags 500 RETQ $ebx 501 bb.1: 502 liveins: $eax, $ebp, $ebx 503 $ebp = LEA32r killed $ebx, 4, killed $ebx, 5, $noreg 504 RETQ $ebp 505 506... 507 508 509 510