xref: /aosp_15_r20/external/llvm/test/CodeGen/SystemZ/branch-08.ll (revision 9880d6810fe72a1726cb53787c6711e909410d58)
1*9880d681SAndroid Build Coastguard Worker; Test SystemZInstrInfo::AnalyzeBranch and SystemZInstrInfo::InsertBranch.
2*9880d681SAndroid Build Coastguard Worker;
3*9880d681SAndroid Build Coastguard Worker; RUN: llc < %s -mtriple=s390x-linux-gnu | FileCheck %s
4*9880d681SAndroid Build Coastguard Worker
5*9880d681SAndroid Build Coastguard Workerdeclare void @foo() noreturn
6*9880d681SAndroid Build Coastguard Worker
7*9880d681SAndroid Build Coastguard Worker; Check a case where a separate branch is needed and where the original
8*9880d681SAndroid Build Coastguard Worker; order should be reversed.
9*9880d681SAndroid Build Coastguard Workerdefine i32 @f1(i32 %a, i32 *%bptr) {
10*9880d681SAndroid Build Coastguard Worker; CHECK-LABEL: f1:
11*9880d681SAndroid Build Coastguard Worker; CHECK: cl %r2, 0(%r3)
12*9880d681SAndroid Build Coastguard Worker; CHECK: jl .L[[LABEL:.*]]
13*9880d681SAndroid Build Coastguard Worker; CHECK: br %r14
14*9880d681SAndroid Build Coastguard Worker; CHECK: .L[[LABEL]]:
15*9880d681SAndroid Build Coastguard Worker; CHECK: brasl %r14, foo@PLT
16*9880d681SAndroid Build Coastguard Workerentry:
17*9880d681SAndroid Build Coastguard Worker  %b = load i32 , i32 *%bptr
18*9880d681SAndroid Build Coastguard Worker  %cmp = icmp ult i32 %a, %b
19*9880d681SAndroid Build Coastguard Worker  br i1 %cmp, label %callit, label %return
20*9880d681SAndroid Build Coastguard Worker
21*9880d681SAndroid Build Coastguard Workercallit:
22*9880d681SAndroid Build Coastguard Worker  call void @foo()
23*9880d681SAndroid Build Coastguard Worker  unreachable
24*9880d681SAndroid Build Coastguard Worker
25*9880d681SAndroid Build Coastguard Workerreturn:
26*9880d681SAndroid Build Coastguard Worker  ret i32 1
27*9880d681SAndroid Build Coastguard Worker}
28*9880d681SAndroid Build Coastguard Worker
29*9880d681SAndroid Build Coastguard Worker; Same again with a fused compare and branch.
30*9880d681SAndroid Build Coastguard Workerdefine i32 @f2(i32 %a) {
31*9880d681SAndroid Build Coastguard Worker; CHECK-LABEL: f2:
32*9880d681SAndroid Build Coastguard Worker; CHECK: cije %r2, 0, .L[[LABEL:.*]]
33*9880d681SAndroid Build Coastguard Worker; CHECK: br %r14
34*9880d681SAndroid Build Coastguard Worker; CHECK: .L[[LABEL]]:
35*9880d681SAndroid Build Coastguard Worker; CHECK: brasl %r14, foo@PLT
36*9880d681SAndroid Build Coastguard Workerentry:
37*9880d681SAndroid Build Coastguard Worker  %cmp = icmp eq i32 %a, 0
38*9880d681SAndroid Build Coastguard Worker  br i1 %cmp, label %callit, label %return
39*9880d681SAndroid Build Coastguard Worker
40*9880d681SAndroid Build Coastguard Workercallit:
41*9880d681SAndroid Build Coastguard Worker  call void @foo()
42*9880d681SAndroid Build Coastguard Worker  unreachable
43*9880d681SAndroid Build Coastguard Worker
44*9880d681SAndroid Build Coastguard Workerreturn:
45*9880d681SAndroid Build Coastguard Worker  ret i32 1
46*9880d681SAndroid Build Coastguard Worker}
47