1 ; RUN: opt %s -simplifycfg -simplifycfg-require-and-preserve-domtree=1 -S | FileCheck %s --check-prefix=NORMAL
2 ; RUN: opt %s -simplifycfg -simplifycfg-require-and-preserve-domtree=1 -S -bonus-inst-threshold=2 | FileCheck %s --check-prefix=AGGRESSIVE
3 ; RUN: opt %s -simplifycfg -simplifycfg-require-and-preserve-domtree=1 -S -bonus-inst-threshold=4 | FileCheck %s --check-prefix=WAYAGGRESSIVE
4 ; RUN: opt %s -passes=simplifycfg -S | FileCheck %s --check-prefix=NORMAL
5 ; RUN: opt %s -passes='simplifycfg<bonus-inst-threshold=2>' -S | FileCheck %s --check-prefix=AGGRESSIVE
6 ; RUN: opt %s -passes='simplifycfg<bonus-inst-threshold=4>' -S | FileCheck %s --check-prefix=WAYAGGRESSIVE
8 define i32 @foo(i32 %a, i32 %b, i32 %c, i32 %d, i32* %input) {
10 ; AGGRESSIVE-LABEL: @foo(
12 %cmp = icmp sgt i32 %d, 3
13 br i1 %cmp, label %cond.end, label %lor.lhs.false
19 %add = add nsw i32 %mul, %a
20 %cmp1 = icmp slt i32 %add, %b
21 br i1 %cmp1, label %cond.false, label %cond.end
23 ; AGGRESSIVE-NOT: br i1
26 %0 = load i32, i32* %input, align 4
30 %cond = phi i32 [ %0, %cond.false ], [ 0, %lor.lhs.false ], [ 0, %entry ]
34 declare void @distinct_a();
35 declare void @distinct_b();
37 ;; Like foo, but have to duplicate into multiple predecessors
38 define i32 @bar(i32 %a, i32 %b, i32 %c, i32 %d, i32* %input) {
40 ; AGGRESSIVE-LABEL: @bar(
42 %cmp_split = icmp slt i32 %d, %b
43 %cmp = icmp sgt i32 %d, 3
44 br i1 %cmp_split, label %pred_a, label %pred_b
46 ; NORMAL-LABEL: pred_a:
47 ; AGGRESSIVE-LABEL: pred_a:
48 ; WAYAGGRESSIVE-LABEL: pred_a:
51 ; WAYAGGRESSIVE: br i1
52 call void @distinct_a();
53 br i1 %cmp, label %cond.end, label %lor.lhs.false
55 ; NORMAL-LABEL: pred_b:
56 ; AGGRESSIVE-LABEL: pred_b:
57 ; WAYAGGRESSIVE-LABEL: pred_b:
60 ; WAYAGGRESSIVE: br i1
61 call void @distinct_b();
62 br i1 %cmp, label %cond.end, label %lor.lhs.false
66 %add = add nsw i32 %mul, %a
67 %cmp1 = icmp slt i32 %add, %b
68 br i1 %cmp1, label %cond.false, label %cond.end
69 ; NORMAL-LABEL: lor.lhs.false:
70 ; AGGRESIVE-LABEL: lor.lhs.false:
71 ; WAYAGGRESIVE-LABEL: lor.lhs.false:
74 ; WAYAGGRESSIVE-NOT: br i1
77 %0 = load i32, i32* %input, align 4
81 %cond = phi i32 [ %0, %cond.false ], [ 0, %lor.lhs.false ],[ 0, %pred_a ],[ 0, %pred_b ]