1 ; NOTE: Assertions have been autogenerated by utils/update_test_checks.py UTC_ARGS: --version 2
2 ; RUN: opt < %s -S -passes='simplifycfg<speculate-blocks>' | FileCheck %s --check-prefix=YES
3 ; RUN: opt < %s -S -passes='simplifycfg<no-speculate-blocks>' | FileCheck %s --check-prefix=NO
6 ; YES-LABEL: define i32 @f
7 ; YES-SAME: (i1 [[A:%.*]]) {
9 ; YES-NEXT: [[SPEC_SELECT:%.*]] = select i1 [[A]], i32 5, i32 2
10 ; YES-NEXT: ret i32 [[SPEC_SELECT]]
12 ; NO-LABEL: define i32 @f
13 ; NO-SAME: (i1 [[A:%.*]]) {
15 ; NO-NEXT: br i1 [[A]], label [[BB:%.*]], label [[BB2:%.*]]
17 ; NO-NEXT: br label [[BB2]]
19 ; NO-NEXT: [[R:%.*]] = phi i32 [ 2, [[ENTRY:%.*]] ], [ 5, [[BB]] ]
20 ; NO-NEXT: ret i32 [[R]]
23 br i1 %a, label %bb, label %bb2
27 %r = phi i32 [ 2, %entry ], [ 5, %bb ]
31 define void @fold_branch_to_common_dest(i8 %v0, i8 %v1) {
32 ; YES-LABEL: define void @fold_branch_to_common_dest
33 ; YES-SAME: (i8 [[V0:%.*]], i8 [[V1:%.*]]) {
35 ; YES-NEXT: [[C0:%.*]] = icmp eq i8 [[V0]], 0
36 ; YES-NEXT: [[C1:%.*]] = icmp eq i8 [[V1]], 0
37 ; YES-NEXT: [[OR_COND:%.*]] = select i1 [[C0]], i1 [[C1]], i1 false
38 ; YES-NEXT: br i1 [[OR_COND]], label [[FINAL_LEFT:%.*]], label [[FINAL_RIGHT:%.*]]
42 ; YES-NEXT: call void @sideeffect0()
43 ; YES-NEXT: br label [[COMMON_RET:%.*]]
45 ; YES-NEXT: call void @sideeffect1()
46 ; YES-NEXT: br label [[COMMON_RET]]
48 ; NO-LABEL: define void @fold_branch_to_common_dest
49 ; NO-SAME: (i8 [[V0:%.*]], i8 [[V1:%.*]]) {
51 ; NO-NEXT: [[C0:%.*]] = icmp eq i8 [[V0]], 0
52 ; NO-NEXT: br i1 [[C0]], label [[DISPATCH:%.*]], label [[FINAL_RIGHT:%.*]]
54 ; NO-NEXT: [[C1:%.*]] = icmp eq i8 [[V1]], 0
55 ; NO-NEXT: br i1 [[C1]], label [[FINAL_LEFT:%.*]], label [[FINAL_RIGHT]]
59 ; NO-NEXT: call void @sideeffect0()
60 ; NO-NEXT: br label [[COMMON_RET:%.*]]
62 ; NO-NEXT: call void @sideeffect1()
63 ; NO-NEXT: br label [[COMMON_RET]]
66 %c0 = icmp eq i8 %v0, 0
67 br i1 %c0, label %dispatch, label %final_right
69 %c1 = icmp eq i8 %v1, 0
70 br i1 %c1, label %final_left, label %final_right
72 call void @sideeffect0()
75 call void @sideeffect1()
79 declare void @sideeffect0()
80 declare void @sideeffect1()