xref: /aosp_15_r20/external/llvm/test/CodeGen/AArch64/branch-relax-asm.ll (revision 9880d6810fe72a1726cb53787c6711e909410d58)
1*9880d681SAndroid Build Coastguard Worker; RUN: llc -mtriple=aarch64-apple-ios7.0 -disable-block-placement -aarch64-tbz-offset-bits=4 -o - %s | FileCheck %s
2*9880d681SAndroid Build Coastguard Workerdefine i32 @test_asm_length(i32 %in) {
3*9880d681SAndroid Build Coastguard Worker; CHECK-LABEL: test_asm_length:
4*9880d681SAndroid Build Coastguard Worker
5*9880d681SAndroid Build Coastguard Worker  ; It would be more natural to use just one "tbnz %false" here, but if the
6*9880d681SAndroid Build Coastguard Worker  ; number of instructions in the asm is counted reasonably, that block is out
7*9880d681SAndroid Build Coastguard Worker  ; of the limited range we gave tbz. So branch relaxation has to invert the
8*9880d681SAndroid Build Coastguard Worker  ; condition.
9*9880d681SAndroid Build Coastguard Worker; CHECK:     tbz w0, #0, [[TRUE:LBB[0-9]+_[0-9]+]]
10*9880d681SAndroid Build Coastguard Worker; CHECK:     b [[FALSE:LBB[0-9]+_[0-9]+]]
11*9880d681SAndroid Build Coastguard Worker
12*9880d681SAndroid Build Coastguard Worker; CHECK: [[TRUE]]:
13*9880d681SAndroid Build Coastguard Worker; CHECK:     orr w0, wzr, #0x4
14*9880d681SAndroid Build Coastguard Worker; CHECK:     nop
15*9880d681SAndroid Build Coastguard Worker; CHECK:     nop
16*9880d681SAndroid Build Coastguard Worker; CHECK:     nop
17*9880d681SAndroid Build Coastguard Worker; CHECK:     nop
18*9880d681SAndroid Build Coastguard Worker; CHECK:     nop
19*9880d681SAndroid Build Coastguard Worker; CHECK:     nop
20*9880d681SAndroid Build Coastguard Worker; CHECK:     ret
21*9880d681SAndroid Build Coastguard Worker
22*9880d681SAndroid Build Coastguard Worker; CHECK: [[FALSE]]:
23*9880d681SAndroid Build Coastguard Worker; CHECK:     ret
24*9880d681SAndroid Build Coastguard Worker
25*9880d681SAndroid Build Coastguard Worker  %val = and i32 %in, 1
26*9880d681SAndroid Build Coastguard Worker  %tst = icmp eq i32 %val, 0
27*9880d681SAndroid Build Coastguard Worker  br i1 %tst, label %true, label %false
28*9880d681SAndroid Build Coastguard Worker
29*9880d681SAndroid Build Coastguard Workertrue:
30*9880d681SAndroid Build Coastguard Worker  call void asm sideeffect "nop\0A\09nop\0A\09nop\0A\09nop\0A\09nop\0A\09nop", ""()
31*9880d681SAndroid Build Coastguard Worker  ret i32 4
32*9880d681SAndroid Build Coastguard Worker
33*9880d681SAndroid Build Coastguard Workerfalse:
34*9880d681SAndroid Build Coastguard Worker  ret i32 0
35*9880d681SAndroid Build Coastguard Worker}
36