xref: /aosp_15_r20/external/llvm/test/Transforms/SimplifyCFG/branch-fold-threshold.ll (revision 9880d6810fe72a1726cb53787c6711e909410d58)
1*9880d681SAndroid Build Coastguard Worker; RUN: opt %s -simplifycfg -S | FileCheck %s --check-prefix=NORMAL
2*9880d681SAndroid Build Coastguard Worker; RUN: opt %s -simplifycfg -S -bonus-inst-threshold=2 | FileCheck %s --check-prefix=AGGRESSIVE
3*9880d681SAndroid Build Coastguard Worker
4*9880d681SAndroid Build Coastguard Workerdefine i32 @foo(i32 %a, i32 %b, i32 %c, i32 %d, i32* %input) {
5*9880d681SAndroid Build Coastguard Worker; NORMAL-LABEL: @foo(
6*9880d681SAndroid Build Coastguard Worker; AGGRESSIVE-LABEL: @foo(
7*9880d681SAndroid Build Coastguard Workerentry:
8*9880d681SAndroid Build Coastguard Worker  %cmp = icmp sgt i32 %d, 3
9*9880d681SAndroid Build Coastguard Worker  br i1 %cmp, label %cond.end, label %lor.lhs.false
10*9880d681SAndroid Build Coastguard Worker; NORMAL: br i1
11*9880d681SAndroid Build Coastguard Worker; AGGRESSIVE: br i1
12*9880d681SAndroid Build Coastguard Worker
13*9880d681SAndroid Build Coastguard Workerlor.lhs.false:
14*9880d681SAndroid Build Coastguard Worker  %mul = shl i32 %c, 1
15*9880d681SAndroid Build Coastguard Worker  %add = add nsw i32 %mul, %a
16*9880d681SAndroid Build Coastguard Worker  %cmp1 = icmp slt i32 %add, %b
17*9880d681SAndroid Build Coastguard Worker  br i1 %cmp1, label %cond.false, label %cond.end
18*9880d681SAndroid Build Coastguard Worker; NORMAL: br i1
19*9880d681SAndroid Build Coastguard Worker; AGGRESSIVE-NOT: br i1
20*9880d681SAndroid Build Coastguard Worker
21*9880d681SAndroid Build Coastguard Workercond.false:
22*9880d681SAndroid Build Coastguard Worker  %0 = load i32, i32* %input, align 4
23*9880d681SAndroid Build Coastguard Worker  br label %cond.end
24*9880d681SAndroid Build Coastguard Worker
25*9880d681SAndroid Build Coastguard Workercond.end:
26*9880d681SAndroid Build Coastguard Worker  %cond = phi i32 [ %0, %cond.false ], [ 0, %lor.lhs.false ], [ 0, %entry ]
27*9880d681SAndroid Build Coastguard Worker  ret i32 %cond
28*9880d681SAndroid Build Coastguard Worker}
29