blob: d868d642e04aaeacb564faaf1ea56cf5a4d06dc4 [file] [edit]
# RUN: llc -o - %s -mtriple=aarch64 -run-pass branch-folder -verify-machineinstrs | FileCheck %s --check-prefix=REORDER
# RUN: llc -o - %s -mtriple=aarch64 -run-pass branch-folder -branch-folder-reorder-blocks=false -verify-machineinstrs | FileCheck %s --check-prefix=NOREORDER
# Check that -branch-folder-reorder-blocks=false disables the basic-block
# reordering sub-phase of branch optimization. bb.1 is a non-fall-through return
# block sitting between the conditional branch in bb.0 and its taken target bb.2.
#
# With reordering enabled (default) BranchFolding reverses the bb.0 condition
# (CBZX -> CBNZX) so it can fall through, and relocates the blocks. With
# reordering disabled the original layout (CBZX; bb.1 is the return block) is
# preserved.
# REORDER-LABEL: name: func
# REORDER: bb.0:
# REORDER: CBNZX $x1, %bb.2
# REORDER: bb.1:
# REORDER: $x0 = ADDXri $x0, 1, 0
# REORDER: $x0 = ADDXri $x0, 2, 0
# REORDER: bb.2:
# REORDER-NOT: ADDXri
# REORDER: RET_ReallyLR implicit $x0
# NOREORDER-LABEL: name: func
# NOREORDER: bb.0:
# NOREORDER: CBZX $x1, %bb.2
# NOREORDER: bb.1:
# NOREORDER: RET_ReallyLR implicit $x0
# NOREORDER: bb.2:
# NOREORDER: $x0 = ADDXri $x0, 1, 0
# NOREORDER: $x0 = ADDXri $x0, 2, 0
# NOREORDER: RET_ReallyLR implicit $x0
name: func
tracksRegLiveness: true
body: |
bb.0:
successors: %bb.1, %bb.2
liveins: $x0, $x1
CBZX $x1, %bb.2
bb.1:
liveins: $x0
RET_ReallyLR implicit $x0
bb.2:
successors: %bb.3
liveins: $x0
$x0 = ADDXri $x0, 1, 0
B %bb.3
bb.3:
liveins: $x0
$x0 = ADDXri $x0, 2, 0
RET_ReallyLR implicit $x0
...