|
| 1 | +# RUN: llc -mtriple=aarch64-linux-gnu -verify-machineinstrs -o - %s \ |
| 2 | +# RUN: -start-before=phi-node-elimination -stop-after=branch-relaxation \ |
| 3 | +# RUN: | FileCheck %s |
| 4 | + |
| 5 | +# Verify an optimal block layout is produced for the following nested loop, when |
| 6 | +# there's a PHI node in bb.5 that relies on an operand in bb.2. |
| 7 | +# The previous layout used a CBNZX for a null check followed by a unconditional |
| 8 | +# branch to bb.6, instead of a fallthrough. |
| 9 | + |
| 10 | +# [ bb.0 ENTRY ] |
| 11 | +# | |
| 12 | +# v |
| 13 | +# [ bb.1 ] <-------+ |
| 14 | +# / \ | |
| 15 | +# v v | |
| 16 | +# [bb.2] [bb.3] <-+ | |
| 17 | +# | | | | |
| 18 | +# | v | | |
| 19 | +# | [bb.4] --+ | |
| 20 | +# | | | |
| 21 | +# v v | |
| 22 | +# [ bb.5 ] | |
| 23 | +# / \ | |
| 24 | +# | v | |
| 25 | +# | [bb.6] -----+ |
| 26 | +# | | |
| 27 | +# v v |
| 28 | +# [ bb.7 RET ] |
| 29 | + |
| 30 | +# CHECK-LABEL: test |
| 31 | +# CHECK-NOT: CBNZX |
| 32 | +# CHECK-NOT: B %bb. |
| 33 | +# CHECK-COUNT-2: CBZX |
| 34 | + |
| 35 | +--- |
| 36 | +name: test |
| 37 | +tracksRegLiveness: true |
| 38 | +body: | |
| 39 | + bb.0: |
| 40 | + successors: %bb.1(0x80000000); %bb.1(100.00%) |
| 41 | + liveins: $x0, $w1, $x2, $x3 |
| 42 | + %0:gpr64all = IMPLICIT_DEF |
| 43 | + %1:gpr64common = IMPLICIT_DEF |
| 44 | + %2:gpr32common = IMPLICIT_DEF |
| 45 | + %3:gpr32 = IMPLICIT_DEF |
| 46 | + B %bb.1 |
| 47 | +
|
| 48 | + bb.1: |
| 49 | + successors: %bb.2(0x30000000), %bb.3(0x50000000); %bb.2(37.50%), %bb.3(62.50%) |
| 50 | + %4:gpr64common = PHI undef %0:gpr64all, %bb.0, %5:gpr64common, %bb.6 |
| 51 | + %6:gpr64 = LDRXui undef %1:gpr64common, 0 :: (load (s64)) |
| 52 | + STRXui killed %4:gpr64common, undef %1:gpr64common, 0 :: (store (s64)) |
| 53 | + CBNZX undef %6:gpr64, %bb.3 |
| 54 | +
|
| 55 | + bb.2: |
| 56 | + successors: %bb.5(0x80000000); %bb.5(100.00%) |
| 57 | + %7:gpr64all = COPY killed %6:gpr64 |
| 58 | + B %bb.5 |
| 59 | +
|
| 60 | + bb.3: |
| 61 | + successors: %bb.5(0x04000000), %bb.4(0x7c000000); %bb.5(3.12%), %bb.4(96.88%) |
| 62 | + dead $wzr = SUBSWrr killed undef %3:gpr32, killed undef %2:gpr32common, implicit-def $nzcv |
| 63 | + Bcc 12, %bb.5, implicit killed undef $nzcv |
| 64 | + B %bb.4 |
| 65 | +
|
| 66 | + bb.4: |
| 67 | + successors: %bb.5(0x04000000), %bb.3(0x7c000000); %bb.5(3.12%), %bb.3(96.88%) |
| 68 | + dead $xzr = SUBSXrr killed undef %6:gpr64, killed undef %6:gpr64, implicit-def $nzcv |
| 69 | + Bcc 1, %bb.3, implicit killed undef $nzcv |
| 70 | +
|
| 71 | + bb.5: |
| 72 | + successors: %bb.7(0x04000000), %bb.6(0x7c000000); %bb.7(3.12%), %bb.6(96.88%) |
| 73 | + %5:gpr64common = PHI %7:gpr64all, %bb.2, undef %0:gpr64all, %bb.3, undef %0:gpr64all, %bb.4 |
| 74 | + CBZX undef %5:gpr64common, %bb.7 |
| 75 | + B %bb.6 |
| 76 | +
|
| 77 | + bb.6: |
| 78 | + successors: %bb.7(0x04000000), %bb.1(0x7c000000); %bb.7(3.12%), %bb.1(96.88%) |
| 79 | + dead $wzr = SUBSWrr killed undef %3:gpr32, killed undef %2:gpr32common, implicit-def $nzcv |
| 80 | + Bcc 12, %bb.7, implicit killed undef $nzcv |
| 81 | + B %bb.1 |
| 82 | +
|
| 83 | + bb.7: |
| 84 | + RET_ReallyLR |
| 85 | +... |
0 commit comments