1 ; RUN: opt %s -simplifycfg -S | FileCheck %s --check-prefix=NORMAL
2 ; RUN: opt %s -simplifycfg -S -bonus-inst-threshold=2 | FileCheck %s --check-prefix=AGGRESSIVE
3 ; RUN: opt %s -simplifycfg -S -bonus-inst-threshold=4 | FileCheck %s --check-prefix=WAYAGGRESSIVE
5 define i32 @foo(i32 %a, i32 %b, i32 %c, i32 %d, i32* %input) {
7 ; AGGRESSIVE-LABEL: @foo(
9 %cmp = icmp sgt i32 %d, 3
10 br i1 %cmp, label %cond.end, label %lor.lhs.false
16 %add = add nsw i32 %mul, %a
17 %cmp1 = icmp slt i32 %add, %b
18 br i1 %cmp1, label %cond.false, label %cond.end
20 ; AGGRESSIVE-NOT: br i1
23 %0 = load i32, i32* %input, align 4
27 %cond = phi i32 [ %0, %cond.false ], [ 0, %lor.lhs.false ], [ 0, %entry ]
31 declare void @distinct_a();
32 declare void @distinct_b();
34 ;; Like foo, but have to duplicate into multiple predecessors
35 define i32 @bar(i32 %a, i32 %b, i32 %c, i32 %d, i32* %input) {
37 ; AGGRESSIVE-LABEL: @bar(
39 %cmp_split = icmp slt i32 %d, %b
40 %cmp = icmp sgt i32 %d, 3
41 br i1 %cmp_split, label %pred_a, label %pred_b
43 ; NORMAL-LABEL: pred_a:
44 ; AGGRESSIVE-LABEL: pred_a:
45 ; WAYAGGRESSIVE-LABEL: pred_a:
48 ; WAYAGGRESSIVE: br i1
49 call void @distinct_a();
50 br i1 %cmp, label %cond.end, label %lor.lhs.false
52 ; NORMAL-LABEL: pred_b:
53 ; AGGRESSIVE-LABEL: pred_b:
54 ; WAYAGGRESSIVE-LABEL: pred_b:
57 ; WAYAGGRESSIVE: br i1
58 call void @distinct_b();
59 br i1 %cmp, label %cond.end, label %lor.lhs.false
63 %add = add nsw i32 %mul, %a
64 %cmp1 = icmp slt i32 %add, %b
65 br i1 %cmp1, label %cond.false, label %cond.end
66 ; NORMAL-LABEL: lor.lhs.false:
67 ; AGGRESIVE-LABEL: lor.lhs.false:
68 ; WAYAGGRESIVE-LABEL: lor.lhs.false:
71 ; WAYAGGRESSIVE-NOT: br i1
74 %0 = load i32, i32* %input, align 4
78 %cond = phi i32 [ %0, %cond.false ], [ 0, %lor.lhs.false ],[ 0, %pred_a ],[ 0, %pred_b ]