1 ; NOTE: Assertions have been autogenerated by utils/update_test_checks.py
2 ; RUN: opt < %s -passes=simplifycfg,adce -simplifycfg-require-and-preserve-domtree=1 -S | FileCheck %s
12 define i32 @test1(i32 %X, i1 %D) {
13 ; CHECK-LABEL: @test1(
15 ; CHECK-NEXT: [[C:%.*]] = icmp eq i32 [[X:%.*]], 0
16 ; CHECK-NEXT: br i1 [[C]], label [[B:%.*]], label [[F:%.*]]
18 ; CHECK-NEXT: [[COMMON_RET_OP:%.*]] = phi i32 [ 345, [[B]] ], [ 123, [[F]] ]
19 ; CHECK-NEXT: ret i32 [[COMMON_RET_OP]]
21 ; CHECK-NEXT: call void @f2()
22 ; CHECK-NEXT: br label [[COMMON_RET:%.*]]
24 ; CHECK-NEXT: call void @f3()
25 ; CHECK-NEXT: br label [[COMMON_RET]]
28 %C = icmp eq i32 %X, 0 ; <i1> [#uses=2]
29 br i1 %C, label %T, label %F
31 br i1 %C, label %B, label %A
34 br i1 %D, label %T, label %F
43 define i32 @test2(i32 %X, i1 %D) {
44 ; CHECK-LABEL: @test2(
46 ; CHECK-NEXT: [[C:%.*]] = icmp eq i32 [[X:%.*]], 0
47 ; CHECK-NEXT: br i1 [[C]], label [[B:%.*]], label [[F:%.*]]
49 ; CHECK-NEXT: [[COMMON_RET_OP:%.*]] = phi i32 [ 345, [[B]] ], [ 123, [[F]] ]
50 ; CHECK-NEXT: ret i32 [[COMMON_RET_OP]]
52 ; CHECK-NEXT: call void @f2()
53 ; CHECK-NEXT: br label [[COMMON_RET:%.*]]
55 ; CHECK-NEXT: call void @f3()
56 ; CHECK-NEXT: br label [[COMMON_RET]]
59 %C = icmp eq i32 %X, 0 ; <i1> [#uses=2]
60 br i1 %C, label %T, label %F
62 %P = phi i1 [ true, %E ], [ %C, %A ] ; <i1> [#uses=1]
63 br i1 %P, label %B, label %A
66 br i1 %D, label %T, label %F
75 define i32 @test3(i32 %X, i1 %D, ptr %AP, ptr %BP) {
76 ; CHECK-LABEL: @test3(
78 ; CHECK-NEXT: [[C:%.*]] = icmp eq i32 [[X:%.*]], 0
79 ; CHECK-NEXT: br i1 [[C]], label [[B_CRITEDGE:%.*]], label [[F:%.*]]
81 ; CHECK-NEXT: [[COMMON_RET_OP:%.*]] = phi i32 [ 345, [[B_CRITEDGE]] ], [ 123, [[F]] ]
82 ; CHECK-NEXT: ret i32 [[COMMON_RET_OP]]
84 ; CHECK-NEXT: call void @f3()
85 ; CHECK-NEXT: [[XX_C:%.*]] = load i32, ptr [[AP:%.*]], align 4
86 ; CHECK-NEXT: store i32 [[XX_C]], ptr [[BP:%.*]], align 4
87 ; CHECK-NEXT: call void @f2()
88 ; CHECK-NEXT: br label [[COMMON_RET:%.*]]
90 ; CHECK-NEXT: call void @f3()
91 ; CHECK-NEXT: br label [[COMMON_RET]]
94 %C = icmp eq i32 %X, 0 ; <i1> [#uses=2]
95 br i1 %C, label %T, label %F
98 %XX = load i32, ptr %AP ; <i32> [#uses=1]
99 store i32 %XX, ptr %BP
100 br i1 %C, label %B, label %A
103 br i1 %D, label %T, label %F