testandor.ll
7.4 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
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
; NOTE: Assertions have been autogenerated by utils/update_test_checks.py
; RUN: opt -print-predicateinfo < %s 2>&1 | FileCheck %s
declare void @foo(i1)
declare void @bar(i32)
declare void @llvm.assume(i1)
define void @testor(i32 %x, i32 %y) {
; CHECK-LABEL: @testor(
; CHECK-NEXT: [[XZ:%.*]] = icmp eq i32 [[X:%.*]], 0
; CHECK-NEXT: [[YZ:%.*]] = icmp eq i32 [[Y:%.*]], 0
; CHECK-NEXT: [[Z:%.*]] = or i1 [[XZ]], [[YZ]]
; CHECK: [[XZ_0:%.*]] = call i1 @llvm.ssa.copy.{{.+}}(i1 [[XZ]])
; CHECK: [[X_0:%.*]] = call i32 @llvm.ssa.copy.{{.+}}(i32 [[X]])
; CHECK: [[YZ_0:%.*]] = call i1 @llvm.ssa.copy.{{.+}}(i1 [[YZ]])
; CHECK: [[Y_0:%.*]] = call i32 @llvm.ssa.copy.{{.+}}(i32 [[Y]])
; CHECK: [[Z_0:%.*]] = call i1 @llvm.ssa.copy.{{.+}}(i1 [[Z]])
; CHECK-NEXT: br i1 [[Z]], label [[ONEOF:%.*]], label [[NEITHER:%.*]]
; CHECK: oneof:
; CHECK-NEXT: call void @foo(i1 [[XZ]])
; CHECK-NEXT: call void @foo(i1 [[YZ]])
; CHECK-NEXT: call void @bar(i32 [[X]])
; CHECK-NEXT: call void @bar(i32 [[Y]])
; CHECK-NEXT: ret void
; CHECK: neither:
; CHECK-NEXT: call void @foo(i1 [[XZ_0]])
; CHECK-NEXT: call void @foo(i1 [[YZ_0]])
; CHECK-NEXT: call void @bar(i32 [[X_0]])
; CHECK-NEXT: call void @bar(i32 [[Y_0]])
; CHECK-NEXT: call void @foo(i1 [[Z_0]])
; CHECK-NEXT: ret void
;
%xz = icmp eq i32 %x, 0
%yz = icmp eq i32 %y, 0
%z = or i1 %xz, %yz
br i1 %z, label %oneof, label %neither
oneof:
;; Should not insert on the true edge for or
call void @foo(i1 %xz)
call void @foo(i1 %yz)
call void @bar(i32 %x)
call void @bar(i32 %y)
ret void
neither:
call void @foo(i1 %xz)
call void @foo(i1 %yz)
call void @bar(i32 %x)
call void @bar(i32 %y)
call void @foo(i1 %z)
ret void
}
define void @testand(i32 %x, i32 %y) {
; CHECK-LABEL: @testand(
; CHECK-NEXT: [[XZ:%.*]] = icmp eq i32 [[X:%.*]], 0
; CHECK-NEXT: [[YZ:%.*]] = icmp eq i32 [[Y:%.*]], 0
; CHECK-NEXT: [[Z:%.*]] = and i1 [[XZ]], [[YZ]]
; CHECK: [[XZ_0:%.*]] = call i1 @llvm.ssa.copy.{{.+}}(i1 [[XZ]])
; CHECK: [[X_0:%.*]] = call i32 @llvm.ssa.copy.{{.+}}(i32 [[X]])
; CHECK: [[YZ_0:%.*]] = call i1 @llvm.ssa.copy.{{.+}}(i1 [[YZ]])
; CHECK: [[Y_0:%.*]] = call i32 @llvm.ssa.copy.{{.+}}(i32 [[Y]])
; CHECK: [[Z_0:%.*]] = call i1 @llvm.ssa.copy.{{.+}}(i1 [[Z]])
; CHECK-NEXT: br i1 [[Z]], label [[BOTH:%.*]], label [[NOPE:%.*]]
; CHECK: both:
; CHECK-NEXT: call void @foo(i1 [[XZ_0]])
; CHECK-NEXT: call void @foo(i1 [[YZ_0]])
; CHECK-NEXT: call void @bar(i32 [[X_0]])
; CHECK-NEXT: call void @bar(i32 [[Y_0]])
; CHECK-NEXT: ret void
; CHECK: nope:
; CHECK-NEXT: call void @foo(i1 [[XZ]])
; CHECK-NEXT: call void @foo(i1 [[YZ]])
; CHECK-NEXT: call void @bar(i32 [[X]])
; CHECK-NEXT: call void @bar(i32 [[Y]])
; CHECK-NEXT: call void @foo(i1 [[Z_0]])
; CHECK-NEXT: ret void
;
%xz = icmp eq i32 %x, 0
%yz = icmp eq i32 %y, 0
%z = and i1 %xz, %yz
br i1 %z, label %both, label %nope
both:
call void @foo(i1 %xz)
call void @foo(i1 %yz)
call void @bar(i32 %x)
call void @bar(i32 %y)
ret void
nope:
;; Should not insert on the false edge for and
call void @foo(i1 %xz)
call void @foo(i1 %yz)
call void @bar(i32 %x)
call void @bar(i32 %y)
call void @foo(i1 %z)
ret void
}
define void @testandsame(i32 %x, i32 %y) {
; CHECK-LABEL: @testandsame(
; CHECK-NEXT: [[XGT:%.*]] = icmp sgt i32 [[X:%.*]], 0
; CHECK-NEXT: [[XLT:%.*]] = icmp slt i32 [[X]], 100
; CHECK-NEXT: [[Z:%.*]] = and i1 [[XGT]], [[XLT]]
; CHECK: [[XGT_0:%.*]] = call i1 @llvm.ssa.copy.{{.+}}(i1 [[XGT]])
; CHECK: [[X_0:%.*]] = call i32 @llvm.ssa.copy.{{.+}}(i32 [[X]])
; CHECK: [[X_0_1:%.*]] = call i32 @llvm.ssa.copy.{{.+}}(i32 [[X_0]])
; CHECK: [[XLT_0:%.*]] = call i1 @llvm.ssa.copy.{{.+}}(i1 [[XLT]])
; CHECK: [[Z_0:%.*]] = call i1 @llvm.ssa.copy.{{.+}}(i1 [[Z]])
; CHECK-NEXT: br i1 [[Z]], label [[BOTH:%.*]], label [[NOPE:%.*]]
; CHECK: both:
; CHECK-NEXT: call void @foo(i1 [[XGT_0]])
; CHECK-NEXT: call void @foo(i1 [[XLT_0]])
; CHECK-NEXT: call void @bar(i32 [[X_0_1]])
; CHECK-NEXT: ret void
; CHECK: nope:
; CHECK-NEXT: call void @foo(i1 [[XGT]])
; CHECK-NEXT: call void @foo(i1 [[XLT]])
; CHECK-NEXT: call void @foo(i1 [[Z_0]])
; CHECK-NEXT: ret void
;
%xgt = icmp sgt i32 %x, 0
%xlt = icmp slt i32 %x, 100
%z = and i1 %xgt, %xlt
br i1 %z, label %both, label %nope
both:
call void @foo(i1 %xgt)
call void @foo(i1 %xlt)
call void @bar(i32 %x)
ret void
nope:
call void @foo(i1 %xgt)
call void @foo(i1 %xlt)
call void @foo(i1 %z)
ret void
}
define void @testandassume(i32 %x, i32 %y) {
; CHECK-LABEL: @testandassume(
; CHECK-NEXT: [[XZ:%.*]] = icmp eq i32 [[X:%.*]], 0
; CHECK-NEXT: [[YZ:%.*]] = icmp eq i32 [[Y:%.*]], 0
; CHECK-NEXT: [[Z:%.*]] = and i1 [[XZ]], [[YZ]]
; CHECK: [[TMP1:%.*]] = call i1 @llvm.ssa.copy.{{.+}}(i1 [[XZ]])
; CHECK: [[TMP2:%.*]] = call i32 @llvm.ssa.copy.{{.+}}(i32 [[X]])
; CHECK: [[TMP3:%.*]] = call i1 @llvm.ssa.copy.{{.+}}(i1 [[YZ]])
; CHECK: [[TMP4:%.*]] = call i32 @llvm.ssa.copy.{{.+}}(i32 [[Y]])
; CHECK: [[TMP5:%.*]] = call i1 @llvm.ssa.copy.{{.+}}(i1 [[Z]])
; CHECK-NEXT: call void @llvm.assume(i1 [[TMP5]])
; CHECK: [[DOT0:%.*]] = call i1 @llvm.ssa.copy.{{.+}}(i1 [[TMP1]])
; CHECK: [[DOT01:%.*]] = call i32 @llvm.ssa.copy.{{.+}}(i32 [[TMP2]])
; CHECK: [[DOT02:%.*]] = call i1 @llvm.ssa.copy.{{.+}}(i1 [[TMP3]])
; CHECK: [[DOT03:%.*]] = call i32 @llvm.ssa.copy.{{.+}}(i32 [[TMP4]])
; CHECK: [[DOT04:%.*]] = call i1 @llvm.ssa.copy.{{.+}}(i1 [[TMP5]])
; CHECK-NEXT: br i1 [[TMP5]], label [[BOTH:%.*]], label [[NOPE:%.*]]
; CHECK: both:
; CHECK-NEXT: call void @foo(i1 [[DOT0]])
; CHECK-NEXT: call void @foo(i1 [[DOT02]])
; CHECK-NEXT: call void @bar(i32 [[DOT01]])
; CHECK-NEXT: call void @bar(i32 [[DOT03]])
; CHECK-NEXT: ret void
; CHECK: nope:
; CHECK-NEXT: call void @foo(i1 [[DOT04]])
; CHECK-NEXT: ret void
;
%xz = icmp eq i32 %x, 0
%yz = icmp eq i32 %y, 0
%z = and i1 %xz, %yz
call void @llvm.assume(i1 %z)
br i1 %z, label %both, label %nope
both:
call void @foo(i1 %xz)
call void @foo(i1 %yz)
call void @bar(i32 %x)
call void @bar(i32 %y)
ret void
nope:
call void @foo(i1 %z)
ret void
}
;; Unlike and/or for branches, assume is *always* true, so we only match and for it
define void @testorassume(i32 %x, i32 %y) {
;
; CHECK-LABEL: @testorassume(
; CHECK-NEXT: [[XZ:%.*]] = icmp eq i32 [[X:%.*]], 0
; CHECK-NEXT: [[YZ:%.*]] = icmp eq i32 [[Y:%.*]], 0
; CHECK-NEXT: [[Z:%.*]] = or i1 [[XZ]], [[YZ]]
; CHECK-NEXT: call void @llvm.assume(i1 [[Z]])
; CHECK: [[Z_0:%.*]] = call i1 @llvm.ssa.copy.{{.+}}(i1 [[Z]])
; CHECK-NEXT: br i1 [[Z]], label [[BOTH:%.*]], label [[NOPE:%.*]]
; CHECK: both:
; CHECK-NEXT: call void @foo(i1 [[XZ]])
; CHECK-NEXT: call void @foo(i1 [[YZ]])
; CHECK-NEXT: call void @bar(i32 [[X]])
; CHECK-NEXT: call void @bar(i32 [[Y]])
; CHECK-NEXT: ret void
; CHECK: nope:
; CHECK-NEXT: call void @foo(i1 [[Z_0]])
; CHECK-NEXT: ret void
;
%xz = icmp eq i32 %x, 0
%yz = icmp eq i32 %y, 0
%z = or i1 %xz, %yz
call void @llvm.assume(i1 %z)
br i1 %z, label %both, label %nope
both:
call void @foo(i1 %xz)
call void @foo(i1 %yz)
call void @bar(i32 %x)
call void @bar(i32 %y)
ret void
nope:
call void @foo(i1 %z)
ret void
}