summaryrefslogtreecommitdiff
path: root/test/Transforms/PredicateSimplifier/predsimplify.ll
blob: ab42b491a1b0da1445df19677951d586f4365267 (plain)
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
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
; RUN: llvm-as < %s | \
; RUN:   opt -predsimplify -instcombine -simplifycfg -S > %t
; RUN: grep -v declare %t | not grep fail
; RUN: grep -v declare %t | grep pass | count 4


define void @test1(i32 %x) {
entry:
	%A = icmp eq i32 %x, 0		; <i1> [#uses=1]
	br i1 %A, label %then.1, label %else.1
then.1:		; preds = %entry
	%B = icmp eq i32 %x, 1		; <i1> [#uses=1]
	br i1 %B, label %then.2, label %else.1
then.2:		; preds = %then.1
	call void (...)* @fail( )
	ret void
else.1:		; preds = %then.1, %entry
	ret void
}

define void @test2(i32 %x) {
entry:
	%A = icmp eq i32 %x, 0		; <i1> [#uses=1]
	%B = icmp eq i32 %x, 1		; <i1> [#uses=1]
	br i1 %A, label %then.1, label %else.1
then.1:		; preds = %entry
	br i1 %B, label %then.2, label %else.1
then.2:		; preds = %then.1
	call void (...)* @fail( )
	ret void
else.1:		; preds = %then.1, %entry
	ret void
}

define void @test3(i32 %x) {
entry:
	%A = icmp eq i32 %x, 0		; <i1> [#uses=1]
	%B = icmp eq i32 %x, 1		; <i1> [#uses=1]
	br i1 %A, label %then.1, label %else.1
then.1:		; preds = %entry
	br i1 %B, label %then.2, label %else.1
then.2:		; preds = %then.1
	call void (...)* @fail( )
	ret void
else.1:		; preds = %then.1, %entry
	ret void
}

define void @test4(i32 %x, i32 %y) {
entry:
	%A = icmp eq i32 %x, 0		; <i1> [#uses=1]
	%B = icmp eq i32 %y, 0		; <i1> [#uses=1]
	%C = and i1 %A, %B		; <i1> [#uses=1]
	br i1 %C, label %then.1, label %else.1
then.1:		; preds = %entry
	%D = icmp eq i32 %x, 0		; <i1> [#uses=1]
	br i1 %D, label %then.2, label %else.2
then.2:		; preds = %then.1
	%E = icmp eq i32 %y, 0		; <i1> [#uses=1]
	br i1 %E, label %else.1, label %else.2
else.1:		; preds = %then.2, %entry
	ret void
else.2:		; preds = %then.2, %then.1
	call void (...)* @fail( )
	ret void
}

define void @test5(i32 %x) {
entry:
	%A = icmp eq i32 %x, 0		; <i1> [#uses=1]
	br i1 %A, label %then.1, label %else.1
then.1:		; preds = %else.1, %entry
	ret void
then.2:		; preds = %else.1
	call void (...)* @fail( )
	ret void
else.1:		; preds = %entry
	%B = icmp eq i32 %x, 0		; <i1> [#uses=1]
	br i1 %B, label %then.2, label %then.1
}

define void @test6(i32 %x, i32 %y) {
entry:
	%A = icmp eq i32 %x, 0		; <i1> [#uses=1]
	%B = icmp eq i32 %y, 0		; <i1> [#uses=1]
	%C = or i1 %A, %B		; <i1> [#uses=1]
	br i1 %C, label %then.1, label %else.1
then.1:		; preds = %else.2, %entry
	ret void
then.2:		; preds = %else.2, %else.1
	call void (...)* @fail( )
	ret void
else.1:		; preds = %entry
	%D = icmp eq i32 %x, 0		; <i1> [#uses=1]
	br i1 %D, label %then.2, label %else.2
else.2:		; preds = %else.1
	%E = icmp ne i32 %y, 0		; <i1> [#uses=1]
	br i1 %E, label %then.1, label %then.2
}

define void @test7(i32 %x) {
entry:
	%A = icmp ne i32 %x, 0		; <i1> [#uses=1]
	%B = xor i1 %A, true		; <i1> [#uses=1]
	br i1 %B, label %then.1, label %else.1
then.1:		; preds = %entry
	%C = icmp eq i32 %x, 1		; <i1> [#uses=1]
	br i1 %C, label %then.2, label %else.1
then.2:		; preds = %then.1
	call void (...)* @fail( )
	ret void
else.1:		; preds = %then.1, %entry
	ret void
}

define void @test8(i32 %x) {
entry:
	%A = add i32 %x, 1		; <i32> [#uses=1]
	%B = icmp eq i32 %x, 0		; <i1> [#uses=1]
	br i1 %B, label %then.1, label %then.2
then.1:		; preds = %entry
	%C = icmp eq i32 %A, 1		; <i1> [#uses=1]
	br i1 %C, label %then.2, label %else.2
then.2:		; preds = %then.1, %entry
	ret void
else.2:		; preds = %then.1
	call void (...)* @fail( )
	ret void
}

define void @test9(i32 %y, i32 %z) {
entry:
	%x = add i32 %y, %z		; <i32> [#uses=1]
	%A = icmp eq i32 %y, 3		; <i1> [#uses=1]
	%B = icmp eq i32 %z, 5		; <i1> [#uses=1]
	%C = and i1 %A, %B		; <i1> [#uses=1]
	br i1 %C, label %cond_true, label %return
cond_true:		; preds = %entry
	%D = icmp eq i32 %x, 8		; <i1> [#uses=1]
	br i1 %D, label %then, label %oops
then:		; preds = %cond_true
	call void (...)* @pass( )
	ret void
oops:		; preds = %cond_true
	call void (...)* @fail( )
	ret void
return:		; preds = %entry
	ret void
}

define void @test10() {
entry:
	%A = alloca i32		; <i32*> [#uses=1]
	%B = icmp eq i32* %A, null		; <i1> [#uses=1]
	br i1 %B, label %cond_true, label %cond_false
cond_true:		; preds = %entry
	call void (...)* @fail( )
	ret void
cond_false:		; preds = %entry
	call void (...)* @pass( )
	ret void
}

define void @switch1(i32 %x) {
entry:
	%A = icmp eq i32 %x, 10		; <i1> [#uses=1]
	br i1 %A, label %return, label %cond_false
cond_false:		; preds = %entry
	switch i32 %x, label %return [
		 i32 9, label %then1
		 i32 10, label %then2
	]
then1:		; preds = %cond_false
	call void (...)* @pass( )
	ret void
then2:		; preds = %cond_false
	call void (...)* @fail( )
	ret void
return:		; preds = %cond_false, %entry
	ret void
}

define void @switch2(i32 %x) {
entry:
	%A = icmp eq i32 %x, 10		; <i1> [#uses=1]
	br i1 %A, label %return, label %cond_false
cond_false:		; preds = %entry
	switch i32 %x, label %return [
		 i32 8, label %then1
		 i32 9, label %then1
		 i32 10, label %then1
	]
then1:		; preds = %cond_false, %cond_false, %cond_false
	%B = icmp ne i32 %x, 8		; <i1> [#uses=1]
	br i1 %B, label %then2, label %return
then2:		; preds = %then1
	call void (...)* @pass( )
	ret void
return:		; preds = %then1, %cond_false, %entry
	ret void
}

define void @switch3(i32 %x) {
entry:
	%A = icmp eq i32 %x, 10		; <i1> [#uses=1]
	br i1 %A, label %return, label %cond_false
cond_false:		; preds = %entry
	switch i32 %x, label %return [
		 i32 9, label %then1
		 i32 10, label %then1
	]
then1:		; preds = %cond_false, %cond_false
	%B = icmp eq i32 %x, 9		; <i1> [#uses=1]
	br i1 %B, label %return, label %oops
oops:		; preds = %then1
	call void (...)* @fail( )
	ret void
return:		; preds = %then1, %cond_false, %entry
	ret void
}

define void @switch4(i32 %x) {
entry:
	%A = icmp eq i32 %x, 10		; <i1> [#uses=1]
	br i1 %A, label %then1, label %cond_false
cond_false:		; preds = %entry
	switch i32 %x, label %default [
		 i32 9, label %then1
		 i32 10, label %then2
	]
then1:		; preds = %default, %cond_false, %entry
	ret void
then2:		; preds = %cond_false
	ret void
default:		; preds = %cond_false
	%B = icmp eq i32 %x, 9		; <i1> [#uses=1]
	br i1 %B, label %oops, label %then1
oops:		; preds = %default
	call void (...)* @fail( )
	ret void
}

define void @select1(i32 %x) {
entry:
	%A = icmp eq i32 %x, 10		; <i1> [#uses=3]
	%B = select i1 %A, i32 1, i32 2		; <i32> [#uses=1]
	%C = icmp eq i32 %B, 1		; <i1> [#uses=1]
	br i1 %C, label %then, label %else
then:		; preds = %entry
	br i1 %A, label %return, label %oops
else:		; preds = %entry
	br i1 %A, label %oops, label %return
oops:		; preds = %else, %then
	call void (...)* @fail( )
	ret void
return:		; preds = %else, %then
	ret void
}

define void @select2(i32 %x) {
entry:
	%A = icmp eq i32 %x, 10		; <i1> [#uses=2]
	%B = select i1 %A, i32 1, i32 2		; <i32> [#uses=1]
	%C = icmp eq i32 %B, 1		; <i1> [#uses=2]
	br i1 %A, label %then, label %else
then:		; preds = %entry
	br i1 %C, label %return, label %oops
else:		; preds = %entry
	br i1 %C, label %oops, label %return
oops:		; preds = %else, %then
	call void (...)* @fail( )
	ret void
return:		; preds = %else, %then
	ret void
}

declare void @fail(...)

declare void @pass(...)