xref: /aosp_15_r20/external/llvm/test/CodeGen/Mips/compactbranches/compact-branch-policy.ll (revision 9880d6810fe72a1726cb53787c6711e909410d58)
1*9880d681SAndroid Build Coastguard Worker; Check that -mips-compact-branches={never,optimal,always} is accepted and honoured.
2*9880d681SAndroid Build Coastguard Worker; RUN: llc -march=mips -mcpu=mips32r6 -mips-compact-branches=never < %s | FileCheck %s -check-prefix=NEVER
3*9880d681SAndroid Build Coastguard Worker; RUN: llc -march=mips -mcpu=mips32r6 -mips-compact-branches=optimal < %s | FileCheck %s -check-prefix=OPTIMAL
4*9880d681SAndroid Build Coastguard Worker; RUN: llc -march=mips -mcpu=mips32r6 -mips-compact-branches=always < %s | FileCheck %s -check-prefix=ALWAYS
5*9880d681SAndroid Build Coastguard Worker
6*9880d681SAndroid Build Coastguard Workerdefine i32 @l(i32 signext %a, i32 signext %b) {
7*9880d681SAndroid Build Coastguard Workerentry:
8*9880d681SAndroid Build Coastguard Worker  %add = add nsw i32 %b, %a
9*9880d681SAndroid Build Coastguard Worker  %cmp = icmp slt i32 %add, 100
10*9880d681SAndroid Build Coastguard Worker; NEVER: beq
11*9880d681SAndroid Build Coastguard Worker; OPTIMAL: beq
12*9880d681SAndroid Build Coastguard Worker; ALWAYS: beqzc
13*9880d681SAndroid Build Coastguard Worker; This nop is required for correct as having (j|b)al as the instruction
14*9880d681SAndroid Build Coastguard Worker; immediately following beqzc would cause a forbidden slot hazard.
15*9880d681SAndroid Build Coastguard Worker; ALWAYS: nop
16*9880d681SAndroid Build Coastguard Worker  br i1 %cmp, label %if.then, label %if.end
17*9880d681SAndroid Build Coastguard Worker
18*9880d681SAndroid Build Coastguard Workerif.then:                                          ; preds = %entry
19*9880d681SAndroid Build Coastguard Worker  %call = tail call i32 @k()
20*9880d681SAndroid Build Coastguard Worker  br label %if.end
21*9880d681SAndroid Build Coastguard Worker
22*9880d681SAndroid Build Coastguard Workerif.end:                                           ; preds = %entry, %if.then
23*9880d681SAndroid Build Coastguard Worker  %call.pn = phi i32 [ %call, %if.then ], [ -1, %entry ]
24*9880d681SAndroid Build Coastguard Worker  %c.0 = add nsw i32 %call.pn, %add
25*9880d681SAndroid Build Coastguard Worker  ret i32 %c.0
26*9880d681SAndroid Build Coastguard Worker}
27*9880d681SAndroid Build Coastguard Worker
28*9880d681SAndroid Build Coastguard Workerdeclare i32 @k() #1
29