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 4; RUN: opt %s -passes=simplify-cfg -S | FileCheck %s --check-prefix=NORMAL 5; RUN: opt %s -passes='simplify-cfg<bonus-inst-threshold=2>' -S | FileCheck %s --check-prefix=AGGRESSIVE 6; RUN: opt %s -passes='simplify-cfg<bonus-inst-threshold=4>' -S | FileCheck %s --check-prefix=WAYAGGRESSIVE 7 8define i32 @foo(i32 %a, i32 %b, i32 %c, i32 %d, i32* %input) { 9; NORMAL-LABEL: @foo( 10; AGGRESSIVE-LABEL: @foo( 11entry: 12 %cmp = icmp sgt i32 %d, 3 13 br i1 %cmp, label %cond.end, label %lor.lhs.false 14; NORMAL: br i1 15; AGGRESSIVE: br i1 16 17lor.lhs.false: 18 %mul = shl i32 %c, 1 19 %add = add nsw i32 %mul, %a 20 %cmp1 = icmp slt i32 %add, %b 21 br i1 %cmp1, label %cond.false, label %cond.end 22; NORMAL: br i1 23; AGGRESSIVE-NOT: br i1 24 25cond.false: 26 %0 = load i32, i32* %input, align 4 27 br label %cond.end 28 29cond.end: 30 %cond = phi i32 [ %0, %cond.false ], [ 0, %lor.lhs.false ], [ 0, %entry ] 31 ret i32 %cond 32} 33 34declare void @distinct_a(); 35declare void @distinct_b(); 36 37;; Like foo, but have to duplicate into multiple predecessors 38define i32 @bar(i32 %a, i32 %b, i32 %c, i32 %d, i32* %input) { 39; NORMAL-LABEL: @bar( 40; AGGRESSIVE-LABEL: @bar( 41entry: 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 45pred_a: 46; NORMAL-LABEL: pred_a: 47; AGGRESSIVE-LABEL: pred_a: 48; WAYAGGRESSIVE-LABEL: pred_a: 49; NORMAL: br i1 50; AGGRESSIVE: br i1 51; WAYAGGRESSIVE: br i1 52 call void @distinct_a(); 53 br i1 %cmp, label %cond.end, label %lor.lhs.false 54pred_b: 55; NORMAL-LABEL: pred_b: 56; AGGRESSIVE-LABEL: pred_b: 57; WAYAGGRESSIVE-LABEL: pred_b: 58; NORMAL: br i1 59; AGGRESSIVE: br i1 60; WAYAGGRESSIVE: br i1 61 call void @distinct_b(); 62 br i1 %cmp, label %cond.end, label %lor.lhs.false 63 64lor.lhs.false: 65 %mul = shl i32 %c, 1 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: 72; NORMAL: br i1 73; AGGRESSIVE: br i1 74; WAYAGGRESSIVE-NOT: br i1 75 76cond.false: 77 %0 = load i32, i32* %input, align 4 78 br label %cond.end 79 80cond.end: 81 %cond = phi i32 [ %0, %cond.false ], [ 0, %lor.lhs.false ],[ 0, %pred_a ],[ 0, %pred_b ] 82 ret i32 %cond 83} 84