Home | History | Annotate | Download | only in AArch64
      1 # RUN: llc -mtriple=aarch64--linux-gnu -run-pass=aarch64-copyelim %s -verify-machineinstrs -o - | FileCheck %s
      2 ---
      3 # CHECK-LABEL: name: test1
      4 # CHECK: ANDSWri $w0, 1, implicit-def $nzcv
      5 # CHECK: bb.1:
      6 # CHECK-NOT: COPY $wzr
      7 name:            test1
      8 tracksRegLiveness: true
      9 body:             |
     10   bb.0.entry:
     11     liveins: $w0, $x1, $x2
     12 
     13     $w0 = ANDSWri $w0, 1, implicit-def $nzcv
     14     STRWui killed $w0, killed $x1, 0
     15     Bcc 1, %bb.2, implicit killed $nzcv
     16     B %bb.1
     17 
     18   bb.1:
     19     liveins: $x2
     20 
     21     $w0 = COPY $wzr
     22     STRWui killed $w0, killed $x2, 0
     23 
     24   bb.2:
     25     RET_ReallyLR
     26 ...
     27 # CHECK-LABEL: name: test2
     28 # CHECK: ANDSXri $x0, 1, implicit-def $nzcv
     29 # CHECK: bb.1:
     30 # CHECK-NOT: COPY $xzr
     31 name:            test2
     32 tracksRegLiveness: true
     33 body:             |
     34   bb.0.entry:
     35     liveins: $x0, $x1, $x2
     36 
     37     $x0 = ANDSXri $x0, 1, implicit-def $nzcv
     38     STRXui killed $x0, killed $x1, 0
     39     Bcc 1, %bb.2, implicit killed $nzcv
     40     B %bb.1
     41 
     42   bb.1:
     43     liveins: $x2
     44 
     45     $x0 = COPY $xzr
     46     STRXui killed $x0, killed $x2, 0
     47 
     48   bb.2:
     49     RET_ReallyLR
     50 ...
     51 # CHECK-LABEL: name: test3
     52 # CHECK: ADDSWri $w0, 1, 0, implicit-def $nzcv
     53 # CHECK: bb.1:
     54 # CHECK-NOT: COPY $wzr
     55 name:            test3
     56 tracksRegLiveness: true
     57 body:             |
     58   bb.0.entry:
     59     liveins: $w0, $x1, $x2
     60 
     61     $w0 = ADDSWri $w0, 1, 0, implicit-def $nzcv
     62     STRWui killed $w0, killed $x1, 0
     63     Bcc 1, %bb.2, implicit killed $nzcv
     64     B %bb.1
     65 
     66   bb.1:
     67     liveins: $x2
     68 
     69     $w0 = COPY $wzr
     70     STRWui killed $w0, killed $x2, 0
     71 
     72   bb.2:
     73     RET_ReallyLR
     74 ...
     75 # CHECK-LABEL: name: test4
     76 # CHECK: ADDSXri $x0, 1, 0, implicit-def $nzcv
     77 # CHECK: bb.1:
     78 # CHECK-NOT: COPY $xzr
     79 name:            test4
     80 tracksRegLiveness: true
     81 body:             |
     82   bb.0.entry:
     83     liveins: $x0, $x1, $x2
     84 
     85     $x0 = ADDSXri $x0, 1, 0, implicit-def $nzcv
     86     STRXui killed $x0, killed $x1, 0
     87     Bcc 1, %bb.2, implicit killed $nzcv
     88     B %bb.1
     89 
     90   bb.1:
     91     liveins: $x2
     92 
     93     $x0 = COPY $xzr
     94     STRXui killed $x0, killed $x2, 0
     95 
     96   bb.2:
     97     RET_ReallyLR
     98 ...
     99 # CHECK-LABEL: name: test5
    100 # CHECK: SUBSWri $w0, 1, 0, implicit-def $nzcv
    101 # CHECK: bb.1:
    102 # CHECK-NOT: COPY $wzr
    103 name:            test5
    104 tracksRegLiveness: true
    105 body:             |
    106   bb.0.entry:
    107     liveins: $w0, $x1, $x2
    108 
    109     $w0 = SUBSWri $w0, 1, 0, implicit-def $nzcv
    110     STRWui killed $w0, killed $x1, 0
    111     Bcc 1, %bb.2, implicit killed $nzcv
    112     B %bb.1
    113 
    114   bb.1:
    115     liveins: $x2
    116 
    117     $w0 = COPY $wzr
    118     STRWui killed $w0, killed $x2, 0
    119 
    120   bb.2:
    121     RET_ReallyLR
    122 ...
    123 # CHECK-LABEL: name: test6
    124 # CHECK: SUBSXri $x0, 1, 0, implicit-def $nzcv
    125 # CHECK: bb.1:
    126 # CHECK-NOT: COPY $xzr
    127 name:            test6
    128 tracksRegLiveness: true
    129 body:             |
    130   bb.0.entry:
    131     liveins: $x0, $x1, $x2
    132 
    133     $x0 = SUBSXri $x0, 1, 0, implicit-def $nzcv
    134     STRXui killed $x0, killed $x1, 0
    135     Bcc 1, %bb.2, implicit killed $nzcv
    136     B %bb.1
    137 
    138   bb.1:
    139     liveins: $x2
    140 
    141     $x0 = COPY $xzr
    142     STRXui killed $x0, killed $x2, 0
    143 
    144   bb.2:
    145     RET_ReallyLR
    146 ...
    147 # CHECK-LABEL: name: test7
    148 # CHECK: ADDSWrr $w0, $w1, implicit-def $nzcv
    149 # CHECK: bb.1:
    150 # CHECK-NOT: COPY $wzr
    151 name:            test7
    152 tracksRegLiveness: true
    153 body:             |
    154   bb.0.entry:
    155     liveins: $w0, $w1, $x2, $x3
    156 
    157     $w0 = ADDSWrr $w0, $w1, implicit-def $nzcv
    158     STRWui killed $w0, killed $x2, 0
    159     Bcc 1, %bb.2, implicit killed $nzcv
    160     B %bb.1
    161 
    162   bb.1:
    163     liveins: $x3
    164 
    165     $w0 = COPY $wzr
    166     STRWui killed $w0, killed $x3, 0
    167 
    168   bb.2:
    169     RET_ReallyLR
    170 ...
    171 # CHECK-LABEL: name: test8
    172 # CHECK: ADDSXrr $x0, $x1, implicit-def $nzcv
    173 # CHECK: bb.1:
    174 # CHECK-NOT: COPY $xzr
    175 name:            test8
    176 tracksRegLiveness: true
    177 body:             |
    178   bb.0.entry:
    179     liveins: $x0, $x1, $x2, $x3
    180 
    181     $x0 = ADDSXrr $x0, $x1, implicit-def $nzcv
    182     STRXui killed $x0, killed $x2, 0
    183     Bcc 1, %bb.2, implicit killed $nzcv
    184     B %bb.1
    185 
    186   bb.1:
    187     liveins: $x3
    188 
    189     $x0 = COPY $xzr
    190     STRXui killed $x0, killed $x3, 0
    191 
    192   bb.2:
    193     RET_ReallyLR
    194 ...
    195 # CHECK-LABEL: name: test9
    196 # CHECK: ANDSWrr $w0, $w1, implicit-def $nzcv
    197 # CHECK: bb.1:
    198 # CHECK-NOT: COPY $wzr
    199 name:            test9
    200 tracksRegLiveness: true
    201 body:             |
    202   bb.0.entry:
    203     liveins: $w0, $w1, $x2, $x3
    204 
    205     $w0 = ANDSWrr $w0, $w1, implicit-def $nzcv
    206     STRWui killed $w0, killed $x2, 0
    207     Bcc 1, %bb.2, implicit killed $nzcv
    208     B %bb.1
    209 
    210   bb.1:
    211     liveins: $x3
    212 
    213     $w0 = COPY $wzr
    214     STRWui killed $w0, killed $x3, 0
    215 
    216   bb.2:
    217     RET_ReallyLR
    218 ...
    219 # CHECK-LABEL: name: test10
    220 # CHECK: ANDSXrr $x0, $x1, implicit-def $nzcv
    221 # CHECK: bb.1:
    222 # CHECK-NOT: COPY $xzr
    223 name:            test10
    224 tracksRegLiveness: true
    225 body:             |
    226   bb.0.entry:
    227     liveins: $x0, $x1, $x2, $x3
    228 
    229     $x0 = ANDSXrr $x0, $x1, implicit-def $nzcv
    230     STRXui killed $x0, killed $x2, 0
    231     Bcc 1, %bb.2, implicit killed $nzcv
    232     B %bb.1
    233 
    234   bb.1:
    235     liveins: $x3
    236 
    237     $x0 = COPY $xzr
    238     STRXui killed $x0, killed $x3, 0
    239 
    240   bb.2:
    241     RET_ReallyLR
    242 ...
    243 # CHECK-LABEL: name: test11
    244 # CHECK: BICSWrr $w0, $w1, implicit-def $nzcv
    245 # CHECK: bb.1:
    246 # CHECK-NOT: COPY $wzr
    247 name:            test11
    248 tracksRegLiveness: true
    249 body:             |
    250   bb.0.entry:
    251     liveins: $w0, $w1, $x2, $x3
    252 
    253     $w0 = BICSWrr $w0, $w1, implicit-def $nzcv
    254     STRWui killed $w0, killed $x2, 0
    255     Bcc 1, %bb.2, implicit killed $nzcv
    256     B %bb.1
    257 
    258   bb.1:
    259     liveins: $x3
    260 
    261     $w0 = COPY $wzr
    262     STRWui killed $w0, killed $x3, 0
    263 
    264   bb.2:
    265     RET_ReallyLR
    266 ...
    267 # CHECK-LABEL: name: test12
    268 # CHECK: BICSXrr $x0, $x1, implicit-def $nzcv
    269 # CHECK: bb.1:
    270 # CHECK-NOT: COPY $xzr
    271 name:            test12
    272 tracksRegLiveness: true
    273 body:             |
    274   bb.0.entry:
    275     liveins: $x0, $x1, $x2, $x3
    276 
    277     $x0 = BICSXrr $x0, $x1, implicit-def $nzcv
    278     STRXui killed $x0, killed $x2, 0
    279     Bcc 1, %bb.2, implicit killed $nzcv
    280     B %bb.1
    281 
    282   bb.1:
    283     liveins: $x3
    284 
    285     $x0 = COPY $xzr
    286     STRXui killed $x0, killed $x3, 0
    287 
    288   bb.2:
    289     RET_ReallyLR
    290 ...
    291 # CHECK-LABEL: name: test13
    292 # CHECK: SUBSWrr $w0, $w1, implicit-def $nzcv
    293 # CHECK: bb.1:
    294 # CHECK-NOT: COPY $wzr
    295 name:            test13
    296 tracksRegLiveness: true
    297 body:             |
    298   bb.0.entry:
    299     liveins: $w0, $w1, $x2, $x3
    300 
    301     $w0 = SUBSWrr $w0, $w1, implicit-def $nzcv
    302     STRWui killed $w0, killed $x2, 0
    303     Bcc 1, %bb.2, implicit killed $nzcv
    304     B %bb.1
    305 
    306   bb.1:
    307     liveins: $x3
    308 
    309     $w0 = COPY $wzr
    310     STRWui killed $w0, killed $x3, 0
    311 
    312   bb.2:
    313     RET_ReallyLR
    314 ...
    315 # CHECK-LABEL: name: test14
    316 # CHECK: SUBSXrr $x0, $x1, implicit-def $nzcv
    317 # CHECK: bb.1:
    318 # CHECK-NOT: COPY $xzr
    319 name:            test14
    320 tracksRegLiveness: true
    321 body:             |
    322   bb.0.entry:
    323     liveins: $x0, $x1, $x2, $x3
    324 
    325     $x0 = SUBSXrr $x0, $x1, implicit-def $nzcv
    326     STRXui killed $x0, killed $x2, 0
    327     Bcc 1, %bb.2, implicit killed $nzcv
    328     B %bb.1
    329 
    330   bb.1:
    331     liveins: $x3
    332 
    333     $x0 = COPY $xzr
    334     STRXui killed $x0, killed $x3, 0
    335 
    336   bb.2:
    337     RET_ReallyLR
    338 ...
    339 # CHECK-LABEL: name: test15
    340 # CHECK: ADDSWrs $w0, $w1, 0, implicit-def $nzcv
    341 # CHECK: bb.1:
    342 # CHECK-NOT: COPY $wzr
    343 name:            test15
    344 tracksRegLiveness: true
    345 body:             |
    346   bb.0.entry:
    347     liveins: $w0, $w1, $x2, $x3
    348 
    349     $w0 = ADDSWrs $w0, $w1, 0, implicit-def $nzcv
    350     STRWui killed $w0, killed $x2, 0
    351     Bcc 1, %bb.2, implicit killed $nzcv
    352     B %bb.1
    353 
    354   bb.1:
    355     liveins: $x3
    356 
    357     $w0 = COPY $wzr
    358     STRWui killed $w0, killed $x3, 0
    359 
    360   bb.2:
    361     RET_ReallyLR
    362 ...
    363 # CHECK-LABEL: name: test16
    364 # CHECK: ADDSXrs $x0, $x1, 0, implicit-def $nzcv
    365 # CHECK: bb.1:
    366 # CHECK-NOT: COPY $xzr
    367 name:            test16
    368 tracksRegLiveness: true
    369 body:             |
    370   bb.0.entry:
    371     liveins: $x0, $x1, $x2, $x3
    372 
    373     $x0 = ADDSXrs $x0, $x1, 0, implicit-def $nzcv
    374     STRXui killed $x0, killed $x2, 0
    375     Bcc 1, %bb.2, implicit killed $nzcv
    376     B %bb.1
    377 
    378   bb.1:
    379     liveins: $x3
    380 
    381     $x0 = COPY $xzr
    382     STRXui killed $x0, killed $x3, 0
    383 
    384   bb.2:
    385     RET_ReallyLR
    386 ...
    387 # CHECK-LABEL: name: test17
    388 # CHECK: ANDSWrs $w0, $w1, 0, implicit-def $nzcv
    389 # CHECK: bb.1:
    390 # CHECK-NOT: COPY $wzr
    391 name:            test17
    392 tracksRegLiveness: true
    393 body:             |
    394   bb.0.entry:
    395     liveins: $w0, $w1, $x2, $x3
    396 
    397     $w0 = ANDSWrs $w0, $w1, 0, implicit-def $nzcv
    398     STRWui killed $w0, killed $x2, 0
    399     Bcc 1, %bb.2, implicit killed $nzcv
    400     B %bb.1
    401 
    402   bb.1:
    403     liveins: $x3
    404 
    405     $w0 = COPY $wzr
    406     STRWui killed $w0, killed $x3, 0
    407 
    408   bb.2:
    409     RET_ReallyLR
    410 ...
    411 # CHECK-LABEL: name: test18
    412 # CHECK: ANDSXrs $x0, $x1, 0, implicit-def $nzcv
    413 # CHECK: bb.1:
    414 # CHECK-NOT: COPY $xzr
    415 name:            test18
    416 tracksRegLiveness: true
    417 body:             |
    418   bb.0.entry:
    419     liveins: $x0, $x1, $x2, $x3
    420 
    421     $x0 = ANDSXrs $x0, $x1, 0, implicit-def $nzcv
    422     STRXui killed $x0, killed $x2, 0
    423     Bcc 1, %bb.2, implicit killed $nzcv
    424     B %bb.1
    425 
    426   bb.1:
    427     liveins: $x3
    428 
    429     $x0 = COPY $xzr
    430     STRXui killed $x0, killed $x3, 0
    431 
    432   bb.2:
    433     RET_ReallyLR
    434 ...
    435 # CHECK-LABEL: name: test19
    436 # CHECK: BICSWrs $w0, $w1, 0, implicit-def $nzcv
    437 # CHECK: bb.1:
    438 # CHECK-NOT: COPY $wzr
    439 name:            test19
    440 tracksRegLiveness: true
    441 body:             |
    442   bb.0.entry:
    443     liveins: $w0, $w1, $x2, $x3
    444 
    445     $w0 = BICSWrs $w0, $w1, 0, implicit-def $nzcv
    446     STRWui killed $w0, killed $x2, 0
    447     Bcc 1, %bb.2, implicit killed $nzcv
    448     B %bb.1
    449 
    450   bb.1:
    451     liveins: $x3
    452 
    453     $w0 = COPY $wzr
    454     STRWui killed $w0, killed $x3, 0
    455 
    456   bb.2:
    457     RET_ReallyLR
    458 ...
    459 # Unicorn test - we can remove a redundant copy and a redundant mov
    460 # CHECK-LABEL: name: test20
    461 # CHECK: SUBSWri $w1, 1, 0, implicit-def $nzcv
    462 # CHECK: bb.1:
    463 # CHECK-NOT: $w0 = COPY $wzr
    464 # CHECK-NOT: $w1 = MOVi32imm 1
    465 name:            test20
    466 tracksRegLiveness: true
    467 body:             |
    468   bb.0.entry:
    469     liveins: $w1, $x2
    470 
    471     $w0 = SUBSWri $w1, 1, 0, implicit-def $nzcv
    472     Bcc 1, %bb.2, implicit killed $nzcv
    473     B %bb.1
    474 
    475   bb.1:
    476     liveins: $x2
    477 
    478     $w0 = COPY $wzr
    479     $w1 = MOVi32imm 1
    480     STRWui killed $w0, $x2, 0
    481     STRWui killed $w1, killed $x2, 1
    482 
    483   bb.2:
    484     RET_ReallyLR
    485 
    486 ...
    487 # Negative test - MOVi32imm clobbers $w0
    488 # CHECK-LABEL: name: test21
    489 # CHECK: ANDSWri $w0, 1, implicit-def $nzcv
    490 # CHECK: bb.1:
    491 # CHECK: $w0 = COPY $wzr
    492 name:            test21
    493 tracksRegLiveness: true
    494 body:             |
    495   bb.0.entry:
    496     liveins: $w0, $x1, $x2
    497 
    498     $w0 = ANDSWri $w0, 1, implicit-def $nzcv
    499     STRWui killed $w0, $x1, 0
    500     $w0 = MOVi32imm -1
    501     STRWui killed $w0, killed $x1, 1
    502     Bcc 1, %bb.2, implicit killed $nzcv
    503     B %bb.1
    504 
    505   bb.1:
    506     liveins: $x2
    507 
    508     $w0 = COPY $wzr
    509     STRWui killed $w0, killed $x2, 0
    510 
    511   bb.2:
    512     RET_ReallyLR
    513 ...
    514 # Negative test - SUBSXri self-clobbers x0, so MOVi64imm can't be removed
    515 # CHECK-LABEL: name: test22
    516 # CHECK: SUBSXri $x0, 1, 0, implicit-def $nzcv
    517 # CHECK: bb.1:
    518 # CHECK: $x0 = MOVi64imm 1
    519 name:            test22
    520 tracksRegLiveness: true
    521 body:             |
    522   bb.0.entry:
    523     liveins: $x0, $x1, $x2
    524 
    525     $x0 = SUBSXri $x0, 1, 0, implicit-def $nzcv
    526     STRXui killed $x0, killed $x1, 0
    527     Bcc 1, %bb.2, implicit killed $nzcv
    528     B %bb.1
    529 
    530   bb.1:
    531     liveins: $x2
    532 
    533     $x0 = MOVi64imm 1
    534     STRXui killed $x0, killed $x2, 0
    535 
    536   bb.2:
    537     RET_ReallyLR
    538 ...
    539 # Negative test - bb.1 has multiple preds
    540 # CHECK-LABEL: name: test23
    541 # CHECK: ADDSWri $w0, 1, 0, implicit-def $nzcv
    542 # CHECK: bb.1:
    543 # CHECK: COPY $wzr
    544 name:            test23
    545 tracksRegLiveness: true
    546 body:             |
    547   bb.0.entry:
    548     liveins: $w0, $x1, $x2
    549 
    550     $w0 = ADDSWri $w0, 1, 0, implicit-def $nzcv
    551     STRWui killed $w0, killed $x1, 0
    552     Bcc 1, %bb.2, implicit killed $nzcv
    553     B %bb.1
    554 
    555   bb.3:
    556     B %bb.1
    557 
    558   bb.1:
    559     liveins: $x2
    560 
    561     $w0 = COPY $wzr
    562     STRWui killed $w0, killed $x2, 0
    563 
    564   bb.2:
    565     RET_ReallyLR
    566