dom.ll
3.52 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
; NOTE: Assertions have been autogenerated by utils/update_test_checks.py
; RUN: opt -constraint-elimination -S %s | FileCheck %s
; RUN: opt -passes=constraint-elimination -S %s | FileCheck %s
; Test cases where both the true and false successors reach the same block,
; dominated by one of them.
declare void @use(i1)
define i32 @test1(i32 %x) {
; CHECK-LABEL: @test1(
; CHECK-NEXT: entry:
; CHECK-NEXT: [[C_1:%.*]] = icmp ule i32 [[X:%.*]], 10
; CHECK-NEXT: br i1 [[C_1]], label [[BB1:%.*]], label [[BB2:%.*]]
; CHECK: bb1:
; CHECK-NEXT: [[C_2:%.*]] = icmp ule i32 [[X]], 10
; CHECK-NEXT: call void @use(i1 true)
; CHECK-NEXT: br label [[BB2]]
; CHECK: bb2:
; CHECK-NEXT: [[C_3:%.*]] = icmp ugt i32 [[X]], 10
; CHECK-NEXT: call void @use(i1 [[C_3]])
; CHECK-NEXT: ret i32 20
;
entry:
%c.1 = icmp ule i32 %x, 10
br i1 %c.1, label %bb1, label %bb2
bb1:
%c.2 = icmp ule i32 %x, 10
call void @use(i1 %c.2)
br label %bb2
bb2:
%c.3 = icmp ugt i32 %x, 10
call void @use(i1 %c.3)
ret i32 20
}
define i32 @test2(i32 %x) {
; CHECK-LABEL: @test2(
; CHECK-NEXT: entry:
; CHECK-NEXT: [[C_1:%.*]] = icmp ule i32 [[X:%.*]], 10
; CHECK-NEXT: br i1 [[C_1]], label [[BB2:%.*]], label [[BB1:%.*]]
; CHECK: bb1:
; CHECK-NEXT: [[C_2:%.*]] = icmp ugt i32 [[X]], 10
; CHECK-NEXT: call void @use(i1 [[C_2]])
; CHECK-NEXT: ret i32 20
; CHECK: bb2:
; CHECK-NEXT: [[C_3:%.*]] = icmp ule i32 [[X]], 10
; CHECK-NEXT: call void @use(i1 true)
; CHECK-NEXT: br label [[BB1]]
;
entry:
%c.1 = icmp ule i32 %x, 10
br i1 %c.1, label %bb2, label %bb1
bb1:
%c.2 = icmp ugt i32 %x, 10
call void @use(i1 %c.2)
ret i32 20
bb2:
%c.3 = icmp ule i32 %x, 10
call void @use(i1 %c.3)
br label %bb1
}
; Test cases where the true/false successors are not domianted by the conditional branching block.
define i32 @test3(i32 %x, i1 %c) {
; CHECK-LABEL: @test3(
; CHECK-NEXT: entry:
; CHECK-NEXT: br i1 [[C:%.*]], label [[BB_COND:%.*]], label [[BB1:%.*]]
; CHECK: bb.cond:
; CHECK-NEXT: [[C_1:%.*]] = icmp ule i32 [[X:%.*]], 10
; CHECK-NEXT: br i1 [[C_1]], label [[BB1]], label [[BB2:%.*]]
; CHECK: bb1:
; CHECK-NEXT: [[C_2:%.*]] = icmp ule i32 [[X]], 10
; CHECK-NEXT: call void @use(i1 [[C_2]])
; CHECK-NEXT: ret i32 10
; CHECK: bb2:
; CHECK-NEXT: [[C_3:%.*]] = icmp ugt i32 [[X]], 10
; CHECK-NEXT: call void @use(i1 true)
; CHECK-NEXT: ret i32 20
;
entry:
br i1 %c, label %bb.cond, label %bb1
bb.cond:
%c.1 = icmp ule i32 %x, 10
br i1 %c.1, label %bb1, label %bb2
bb1:
%c.2 = icmp ule i32 %x, 10
call void @use(i1 %c.2)
ret i32 10
bb2:
%c.3 = icmp ugt i32 %x, 10
call void @use(i1 %c.3)
ret i32 20
}
define i32 @test4(i32 %x, i1 %c) {
; CHECK-LABEL: @test4(
; CHECK-NEXT: entry:
; CHECK-NEXT: br i1 [[C:%.*]], label [[BB_COND:%.*]], label [[BB2:%.*]]
; CHECK: bb.cond:
; CHECK-NEXT: [[C_1:%.*]] = icmp ule i32 [[X:%.*]], 10
; CHECK-NEXT: br i1 [[C_1]], label [[BB1:%.*]], label [[BB2]]
; CHECK: bb1:
; CHECK-NEXT: [[C_2:%.*]] = icmp ule i32 [[X]], 10
; CHECK-NEXT: call void @use(i1 true)
; CHECK-NEXT: ret i32 10
; CHECK: bb2:
; CHECK-NEXT: [[C_3:%.*]] = icmp ugt i32 [[X]], 10
; CHECK-NEXT: call void @use(i1 [[C_3]])
; CHECK-NEXT: ret i32 20
;
entry:
br i1 %c, label %bb.cond, label %bb2
bb.cond:
%c.1 = icmp ule i32 %x, 10
br i1 %c.1, label %bb1, label %bb2
bb1:
%c.2 = icmp ule i32 %x, 10
call void @use(i1 %c.2)
ret i32 10
bb2:
%c.3 = icmp ugt i32 %x, 10
call void @use(i1 %c.3)
ret i32 20
}