Home | History | Annotate | Download | only in AArch64
      1 # RUN: llc -mtriple=aarch64-none-linux-gnu -run-pass=postra-machine-sink -verify-machineinstrs  -o - %s | FileCheck %s
      2 
      3 ---
      4 # Sink w19 to %bb.1.
      5 # CHECK-LABEL: name: sinkcopy1
      6 # CHECK-LABEL: bb.0:
      7 # CHECK-NOT: $w19 = COPY killed $w0
      8 # CHECK-LABEL: bb.1:
      9 # CHECK: liveins: $w1, $w0
     10 # CHECK: renamable $w19 = COPY killed $w0
     11 
     12 name: sinkcopy1
     13 tracksRegLiveness: true
     14 body: |
     15   bb.0:
     16     liveins: $w0, $w1
     17     $w1 = SUBSWri $w1, 1, 0, implicit-def $nzcv
     18     renamable  $w19 = COPY killed $w0
     19     Bcc 11, %bb.1, implicit $nzcv
     20     B %bb.2
     21 
     22   bb.1:
     23     liveins: $w1, $w19
     24     $w0 = ADDWrr $w1, $w19
     25     RET $x0
     26 
     27   bb.2:
     28     $w0 = COPY $wzr
     29     RET   $x0
     30 ...
     31 
     32 ---
     33 # Sink w19 to %bb.2.
     34 # CHECK-LABEL: name: sinkcopy2
     35 # CHECK-LABEL: bb.0:
     36 # CHECK-NOT: renamable $w19 = COPY killed $w0
     37 # CHECK-LABEL: bb.2:
     38 # CHECK: liveins: $w1, $w0
     39 # CHECK: renamable $w19 = COPY killed $w0
     40 name: sinkcopy2
     41 tracksRegLiveness: true
     42 body: |
     43   bb.0:
     44     liveins: $w0, $w1
     45     $w1 = SUBSWri $w1, 1, 0, implicit-def $nzcv
     46     renamable $w19 = COPY killed $w0
     47     Bcc 11, %bb.2, implicit $nzcv
     48     B %bb.1
     49 
     50   bb.1:
     51     $w0 = COPY $wzr
     52     RET $x0
     53 
     54   bb.2:
     55     liveins: $w1, $w19
     56     $w0 = ADDWrr $w1, $w19
     57     RET $x0
     58 ...
     59 
     60 ---
     61 # Sink w19 and w20 to %bb.1.
     62 # CHECK-LABEL: name: sinkcopy3
     63 # CHECK-LABEL: bb.0:
     64 # CHECK-NOT: renamable $w19 = COPY killed $w0
     65 # CHECK-LABEL: bb.1:
     66 # CHECK: liveins: $w1, $w0
     67 # CHECK: renamable $w19 = COPY killed $w0
     68 # CHECK: renamable $w20 = COPY killed $w1
     69 name: sinkcopy3
     70 tracksRegLiveness: true
     71 body: |
     72   bb.0:
     73     liveins: $w0, $w1
     74     $w1 = SUBSWri $w1, 1, 0, implicit-def $nzcv
     75     renamable $w19 = COPY killed $w0
     76     renamable $w20 = COPY killed $w1
     77 
     78   bb.1:
     79     liveins: $w19, $w20
     80     $w0 = COPY $w19
     81     $w1 = COPY $w20
     82     RET $x0
     83 ...
     84 
     85 
     86 # Sink w19 to %bb.1 and w20 to %bb.2.
     87 # CHECK-LABEL: name: sinkcopy4
     88 # CHECK-LABEL: bb.0:
     89 # CHECK-NOT: renamable $w19 = COPY killed $w0
     90 # CHECK-NOT: renamable $w20 = COPY killed $w1
     91 # CHECK-LABEL: bb.1:
     92 # CHECK: liveins: $w1, $w0
     93 # CHECK: renamable $w19 = COPY killed $w0
     94 # CHECK-LABEL: bb.2:
     95 # CHECK: liveins: $w0, $w1
     96 # CHECK: renamable $w20 = COPY killed $w1
     97 name: sinkcopy4
     98 tracksRegLiveness: true
     99 body: |
    100   bb.0:
    101     liveins: $w0, $w1
    102     $w1 = SUBSWri $w1, 1, 0, implicit-def $nzcv
    103     renamable $w19 = COPY killed $w0
    104     renamable $w20 = COPY killed $w1
    105     Bcc 11, %bb.2, implicit $nzcv
    106     B %bb.1
    107 
    108   bb.1:
    109     liveins: $w1, $w19
    110     $w0 = ADDWrr $w1, $w19
    111     RET $x0
    112 
    113   bb.2:
    114     liveins: $w0, $w20
    115     $w0 = ADDWrr $w0, $w20
    116     RET $x0
    117 ...
    118 
    119 # Sink w19 to %bb.3 through %bb.2.
    120 # CHECK-LABEL: name: sinkcopy5
    121 # CHECK-LABEL: bb.0:
    122 # CHECK-NOT: renamable $w19 = COPY $w0
    123 # CHECK-LABEL: bb.2:
    124 # CHECK: $w1 = ADDWrr $w1, $w0
    125 # CHECK-LABEL: bb.3:
    126 # CHECK: liveins: $w1, $w0
    127 # CHECK: renamable $w19 = COPY killed $w0
    128 name: sinkcopy5
    129 tracksRegLiveness: true
    130 body: |
    131   bb.0:
    132     liveins: $w0, $w1
    133     $w1 = SUBSWri $w1, 1, 0, implicit-def $nzcv
    134     renamable $w19 = COPY $w0
    135     Bcc 11, %bb.2, implicit $nzcv
    136 
    137   bb.1:
    138     liveins: $x0
    139     $w19 = COPY $wzr
    140     RET $x0
    141 
    142   bb.2:
    143     liveins: $w0, $w1, $w19
    144     $w1 = ADDWrr $w1, killed $w0
    145 
    146   bb.3:
    147     liveins: $w1, $w19
    148     $w0 = ADDWrr $w1, $w19
    149     RET $x0
    150 ...
    151 
    152 # Sink w19 to %bb.3, but  through %bb.2.
    153 # CHECK-LABEL: name: sinkcopy6
    154 # CHECK-LABEL: bb.0:
    155 # CHECK-NOT: renamable $w19 = COPY $w0
    156 # CHECK-NOT: renamable $w20 = COPY $w0
    157 # CHECK-LABEL: bb.2:
    158 # CHECK: liveins: $w1, $w0
    159 # CHECK: renamable $w19 = COPY $w0
    160 # CHECK: renamable $w20 = COPY $w19
    161 name: sinkcopy6
    162 tracksRegLiveness: true
    163 body: |
    164   bb.0:
    165     liveins: $w0, $w1
    166     $w1 = SUBSWri $w1, 1, 0, implicit-def $nzcv
    167     renamable $w19 = COPY $w0
    168     renamable $w20 = COPY $w19
    169     Bcc 11, %bb.2, implicit $nzcv
    170 
    171   bb.1:
    172     $w0 = COPY $wzr
    173     RET $x0
    174 
    175   bb.2:
    176     liveins: $w1, $w20
    177     $w0 = ADDWrr killed $w1, $w20
    178     RET $x0
    179 ...
    180 
    181 ---
    182 # Sink w19 regardless of the def of wzr in bb.0.
    183 # CHECK-LABEL: name: sinkcopy7
    184 # CHECK-LABEL: bb.0:
    185 # CHECK-NOT: renamable $w19 = COPY $w0
    186 # CHECK-LABEL: bb.2:
    187 # CHECK: renamable $w19 = COPY $wzr
    188 name: sinkcopy7
    189 tracksRegLiveness: true
    190 body: |
    191   bb.0:
    192     liveins: $w0, $w1
    193     renamable $w19 = COPY $wzr
    194     $wzr = SUBSWri $w1, 1, 0, implicit-def $nzcv
    195     Bcc 11, %bb.2, implicit $nzcv
    196     B %bb.1
    197 
    198   bb.1:
    199     $x0 = COPY $xzr
    200     RET $x0
    201 
    202   bb.2:
    203     liveins: $w0, $w19
    204     $w0 = ADDWrr $w0, $w19
    205     RET $x0
    206 ...
    207 
    208 ---
    209 # Sink w19 to %bb.3 through %bb.2.
    210 # CHECK-LABEL: name: sinkcopy8
    211 # CHECK-LABEL: bb.0:
    212 # CHECK-NOT: renamable $w19 = COPY $w0, implicit-def $x19
    213 # CHECK-LABEL: bb.2:
    214 # CHECK: $w1 = ADDWrr $w1, $w0, implicit $x0
    215 # CHECK-LABEL: bb.3:
    216 # CHECK: liveins: $x1, $w0
    217 # CHECK: renamable $w19 = COPY killed $w0, implicit-def $x19
    218 name: sinkcopy8
    219 tracksRegLiveness: true
    220 body: |
    221   bb.0:
    222     liveins: $w0, $x1
    223     $w1 = SUBSWri $w1, 1, 0, implicit-def $nzcv
    224     renamable $w19 = COPY $w0, implicit-def $x19
    225     Bcc 11, %bb.2, implicit $nzcv
    226 
    227   bb.1:
    228     liveins: $x0
    229     $w19 = COPY $wzr
    230     RET $x0
    231 
    232   bb.2:
    233     liveins: $w0, $x1, $x19
    234     $w1 = ADDWrr $w1, $w0, implicit killed $x0
    235 
    236   bb.3:
    237     liveins: $x1, $x19
    238     $x0 = ADDXrr $x1, $x19
    239     RET $x0
    240 ...
    241 
    242 ---
    243 # Don't sink w19 as w0 is defined in bb.0.
    244 # CHECK-LABEL: name: donotsinkcopy1
    245 # CHECK-LABEL: bb.0:
    246 # CHECK: renamable $w19 = COPY $w0
    247 # CHECK: $w0 = LDRWui $sp, 0
    248 name: donotsinkcopy1
    249 tracksRegLiveness: true
    250 body: |
    251   bb.0:
    252     liveins: $w0, $w1
    253     $w1 = SUBSWri $w1, 1, 0, implicit-def $nzcv
    254     renamable $w19 = COPY $w0
    255     $w0 = LDRWui $sp, 0 :: (load 4)
    256     Bcc 11, %bb.2, implicit $nzcv
    257     B %bb.1
    258 
    259   bb.1:
    260     $x0 = COPY $xzr
    261     RET $x0
    262 
    263   bb.2:
    264     liveins: $w0, $w19
    265     $w0 = ADDWrr $w0, $w19
    266     RET $x0
    267 ...
    268 
    269 ---
    270 # Don't sink w19 as w19 is used in bb.0.
    271 # CHECK-LABEL: name: donotsinkcopy2
    272 # CHECK-LABEL: bb.0:
    273 # CHECK: renamable $w19 = COPY $w0
    274 # CHECK: STRWui $w1, $x19, 0
    275 name: donotsinkcopy2
    276 tracksRegLiveness: true
    277 body: |
    278   bb.0:
    279     liveins: $w0, $w1
    280     $w1 = SUBSWri $w1, 1, 0, implicit-def $nzcv
    281     renamable $w19 = COPY $w0
    282     STRWui $w1, $x19, 0 :: (store 4)
    283     Bcc 11, %bb.2, implicit $nzcv
    284     B %bb.1
    285 
    286   bb.1:
    287     $x0 = COPY $xzr
    288     RET $x0
    289 
    290   bb.2:
    291     liveins: $w0, $w19
    292     $w0 = ADDWrr $w0, $w19
    293     RET $x0
    294 ...
    295 
    296 ---
    297 # Don't sink w19 as w19 is used in both %bb.1 and %bb.2.
    298 # CHECK-LABEL: name: donotsinkcopy3
    299 # CHECK-LABEL: bb.0:
    300 # CHECK: renamable $w19 = COPY $w0
    301 name: donotsinkcopy3
    302 tracksRegLiveness: true
    303 body: |
    304   bb.0:
    305     liveins: $w0, $w1
    306     $w1 = SUBSWri $w1, 1, 0, implicit-def $nzcv
    307     renamable $w19 = COPY $w0
    308     Bcc 11, %bb.2, implicit $nzcv
    309     B %bb.1
    310 
    311   bb.1:
    312     liveins: $w19
    313     $w0 = COPY $w19
    314     RET $x0
    315 
    316   bb.2:
    317     liveins: $w0, $w19
    318     $w0 = ADDWrr $w0, $w19
    319     RET $x0
    320 ...
    321 
    322 ---
    323 # Don't sink w19 as %bb.2 has multiple predecessors.
    324 # CHECK-LABEL: name: donotsinkcopy4
    325 # CHECK-LABEL: bb.0:
    326 # CHECK: renamable $w19 = COPY $w0
    327 name: donotsinkcopy4
    328 tracksRegLiveness: true
    329 body: |
    330   bb.0:
    331     liveins: $w0, $w1
    332     $w1 = SUBSWri $w1, 1, 0, implicit-def $nzcv
    333     renamable $w19 = COPY $w0
    334     Bcc 11, %bb.2, implicit $nzcv
    335     B %bb.1
    336 
    337   bb.1:
    338     liveins: $w0
    339     $w19 = COPY $w0
    340     B %bb.2
    341 
    342   bb.2:
    343     liveins: $w0, $w19
    344     $w0 = ADDWrr $w0, $w19
    345     RET $x0
    346 ...
    347 
    348 
    349 # Don't sink w19 after sinking w20.
    350 # CHECK-LABEL: name: donotsinkcopy5
    351 # CHECK-LABEL: bb.0:
    352 # CHECK: renamable $w19 = COPY $w0
    353 # CHECK-LABEL: bb.2:
    354 # CHECK: liveins: $w0, $w19
    355 # CHECK: renamable $w20 = COPY $w19
    356 name: donotsinkcopy5
    357 tracksRegLiveness: true
    358 body: |
    359   bb.0:
    360     liveins: $w0, $w1
    361     $w1 = SUBSWri $w1, 1, 0, implicit-def $nzcv
    362     renamable $w19 = COPY $w0
    363     renamable $w20 = COPY $w19
    364     Bcc 11, %bb.2, implicit $nzcv
    365 
    366   bb.1:
    367     liveins: $w19
    368     $w0 = COPY $w19
    369     RET $x0
    370 
    371   bb.2:
    372     liveins: $w0, $w20
    373     $w0 = ADDWrr killed $w0, $w20
    374     RET $x0
    375 ...
    376 
    377 ---
    378 # Don't sink w19 as x19 is live-in in %bb.2.
    379 # CHECK-LABEL: name: donotsinkcopy6
    380 # CHECK-LABEL: bb.0:
    381 name: donotsinkcopy6
    382 tracksRegLiveness: true
    383 body: |
    384   bb.0:
    385     liveins: $x0, $w1
    386     $w1 = SUBSWri $w1, 1, 0, implicit-def $nzcv
    387     renamable $x19 = COPY $x0
    388     Bcc 11, %bb.2, implicit $nzcv
    389     B %bb.1
    390 
    391   bb.1:
    392     liveins: $w19
    393     $w0 = COPY $w19
    394     RET $x0
    395 
    396   bb.2:
    397     liveins: $x0, $x19
    398     $x0 = ADDXrr $x0, $x19
    399     RET $x0
    400 ...
    401