1 ; NOTE: Assertions have been autogenerated by utils/update_test_checks.py
2 ; RUN: opt -S -passes=simplifycfg -simplifycfg-require-and-preserve-domtree < %s | FileCheck %s
6 define void @br_undef_simple() {
7 ; CHECK-LABEL: @br_undef_simple(
8 ; CHECK-NEXT: call void @foo(i32 0)
9 ; CHECK-NEXT: br i1 undef, label [[IF:%.*]], label [[ELSE:%.*]]
11 ; CHECK-NEXT: ret void
13 ; CHECK-NEXT: call void @foo(i32 1)
14 ; CHECK-NEXT: br label [[COMMON_RET:%.*]]
16 ; CHECK-NEXT: call void @foo(i32 2)
17 ; CHECK-NEXT: br label [[COMMON_RET]]
20 br i1 undef, label %if, label %else
31 define void @br_poison_simple() {
32 ; CHECK-LABEL: @br_poison_simple(
33 ; CHECK-NEXT: call void @foo(i32 0)
34 ; CHECK-NEXT: br i1 poison, label [[IF:%.*]], label [[ELSE:%.*]]
36 ; CHECK-NEXT: ret void
38 ; CHECK-NEXT: call void @foo(i32 1)
39 ; CHECK-NEXT: br label [[COMMON_RET:%.*]]
41 ; CHECK-NEXT: call void @foo(i32 2)
42 ; CHECK-NEXT: br label [[COMMON_RET]]
45 br i1 poison, label %if, label %else
56 define void @br_poison_succs_used(i32 %v) {
57 ; CHECK-LABEL: @br_poison_succs_used(
59 ; CHECK-NEXT: switch i32 [[V:%.*]], label [[BR:%.*]] [
60 ; CHECK-NEXT: i32 1, label [[IF:%.*]]
61 ; CHECK-NEXT: i32 2, label [[ELSE:%.*]]
64 ; CHECK-NEXT: call void @foo(i32 0)
65 ; CHECK-NEXT: br i1 poison, label [[IF]], label [[ELSE]]
67 ; CHECK-NEXT: ret void
69 ; CHECK-NEXT: [[PHI1:%.*]] = phi i32 [ 1, [[BR]] ], [ 2, [[ENTRY:%.*]] ]
70 ; CHECK-NEXT: call void @foo(i32 [[PHI1]])
71 ; CHECK-NEXT: br label [[COMMON_RET:%.*]]
73 ; CHECK-NEXT: [[PHI2:%.*]] = phi i32 [ 3, [[BR]] ], [ 4, [[ENTRY]] ]
74 ; CHECK-NEXT: call void @foo(i32 [[PHI2]])
75 ; CHECK-NEXT: br label [[COMMON_RET]]
78 switch i32 %v, label %br [
85 br i1 poison, label %if, label %else
88 %phi1 = phi i32 [ 1, %br ], [ 2, %entry ]
89 call void @foo(i32 %phi1)
93 %phi2 = phi i32 [ 3, %br ], [ 4, %entry ]
94 call void @foo(i32 %phi2)