1 USING: arrays compiler.cfg.alias-analysis compiler.cfg.instructions
2 compiler.cfg.registers compiler.cfg.debugger compiler.cfg.comparisons
3 cpu.architecture tools.test byte-arrays layouts literals alien
5 IN: compiler.cfg.alias-analysis.tests
7 : test-alias-analysis ( insn -- insn )
12 ! Redundant load elimination
16 T{ ##slot-imm f 1 0 1 0 }
17 T{ ##copy f 2 1 any-rep }
22 T{ ##slot-imm f 1 0 1 0 }
23 T{ ##slot-imm f 2 0 1 0 }
27 ! Store-load forwarding
32 T{ ##set-slot-imm f 1 0 1 0 }
33 T{ ##copy f 2 1 any-rep }
39 T{ ##set-slot-imm f 1 0 1 0 }
40 T{ ##slot-imm f 2 0 1 0 }
44 ! Dead store elimination
50 T{ ##set-slot-imm f 2 0 1 0 }
57 T{ ##set-slot-imm f 1 0 1 0 }
58 T{ ##set-slot-imm f 2 0 1 0 }
68 T{ ##set-slot-imm f 3 0 1 0 }
76 T{ ##set-slot-imm f 1 0 1 0 }
77 T{ ##set-slot-imm f 2 0 1 0 }
78 T{ ##set-slot-imm f 3 0 1 0 }
82 ! Redundant store elimination
86 T{ ##slot-imm f 1 0 1 0 }
91 T{ ##slot-imm f 1 0 1 0 }
92 T{ ##set-slot-imm f 1 0 1 0 }
99 T{ ##slot-imm f 1 0 1 0 }
100 T{ ##copy f 2 1 any-rep }
105 T{ ##slot-imm f 1 0 1 0 }
106 T{ ##copy f 2 1 any-rep }
107 T{ ##set-slot-imm f 2 0 1 0 }
108 } test-alias-analysis
111 ! Not a redundant load
116 T{ ##slot-imm f 1 0 1 0 }
117 T{ ##set-slot-imm f 0 1 1 0 }
118 T{ ##slot-imm f 2 0 1 0 }
124 T{ ##slot-imm f 1 0 1 0 }
125 T{ ##set-slot-imm f 0 1 1 0 }
126 T{ ##slot-imm f 2 0 1 0 }
127 } test-alias-analysis
130 ! Not a redundant store
137 T{ ##set-slot-imm f 2 1 1 0 }
138 T{ ##slot-imm f 4 0 1 0 }
139 T{ ##set-slot-imm f 3 1 1 0 }
147 T{ ##set-slot-imm f 2 1 1 0 }
148 T{ ##slot-imm f 4 0 1 0 }
149 T{ ##set-slot-imm f 3 1 1 0 }
150 } test-alias-analysis
153 ! There's a redundant load, but not a redundant store
160 T{ ##slot-imm f 4 0 1 0 }
161 T{ ##set-slot-imm f 2 0 1 0 }
162 T{ ##slot f 5 0 3 0 0 }
163 T{ ##set-slot-imm f 3 0 1 0 }
164 T{ ##copy f 6 3 any-rep }
172 T{ ##slot-imm f 4 0 1 0 }
173 T{ ##set-slot-imm f 2 0 1 0 }
174 T{ ##slot f 5 0 3 0 0 }
175 T{ ##set-slot-imm f 3 0 1 0 }
176 T{ ##slot-imm f 6 0 1 0 }
177 } test-alias-analysis
180 ! Fresh allocations don't alias existing values
182 ! Redundant load elimination
188 T{ ##allot f 4 16 array }
189 T{ ##set-slot-imm f 3 4 1 0 }
190 T{ ##set-slot-imm f 2 1 1 0 }
191 T{ ##copy f 5 3 any-rep }
198 T{ ##allot f 4 16 array }
199 T{ ##set-slot-imm f 3 4 1 0 }
200 T{ ##set-slot-imm f 2 1 1 0 }
201 T{ ##slot-imm f 5 4 1 0 }
202 } test-alias-analysis
205 ! Redundant store elimination
211 T{ ##allot f 4 16 array }
212 T{ ##slot-imm f 5 1 1 0 }
213 T{ ##set-slot-imm f 3 4 1 0 }
220 T{ ##allot f 4 16 array }
221 T{ ##set-slot-imm f 1 4 1 0 }
222 T{ ##slot-imm f 5 1 1 0 }
223 T{ ##set-slot-imm f 3 4 1 0 }
224 } test-alias-analysis
227 ! Storing a new alias class into another object means that heap-ac
228 ! can now alias the new ac
235 T{ ##allot f 4 16 array }
236 T{ ##set-slot-imm f 0 4 1 0 }
237 T{ ##set-slot-imm f 4 2 1 0 }
238 T{ ##slot-imm f 5 3 1 0 }
239 T{ ##set-slot-imm f 1 5 1 0 }
240 T{ ##slot-imm f 6 4 1 0 }
248 T{ ##allot f 4 16 array }
249 T{ ##set-slot-imm f 0 4 1 0 }
250 T{ ##set-slot-imm f 4 2 1 0 }
251 T{ ##slot-imm f 5 3 1 0 }
252 T{ ##set-slot-imm f 1 5 1 0 }
253 T{ ##slot-imm f 6 4 1 0 }
254 } test-alias-analysis
257 ! Compares between objects which cannot alias are eliminated
261 T{ ##allot f 1 16 array }
262 T{ ##load-reference f 2 f }
267 T{ ##allot f 1 16 array }
268 T{ ##compare f 2 0 1 cc= }
269 } test-alias-analysis
272 ! Make sure that input to ##box-displaced-alien becomes heap-ac
275 T{ ##allot f 1 16 byte-array }
276 T{ ##load-reference f 2 10 }
277 T{ ##box-displaced-alien f 3 2 1 4 byte-array }
278 T{ ##slot-imm f 5 3 1 $[ alien type-number ] }
279 T{ ##compare f 6 5 1 cc= }
283 T{ ##allot f 1 16 byte-array }
284 T{ ##load-reference f 2 10 }
285 T{ ##box-displaced-alien f 3 2 1 4 byte-array }
286 T{ ##slot-imm f 5 3 1 $[ alien type-number ] }
287 T{ ##compare f 6 5 1 cc= }
288 } test-alias-analysis
291 ! We can't make any assumptions about heap-ac between
292 ! instructions which can call back into Factor code
296 T{ ##slot-imm f 1 0 1 0 }
297 T{ ##alien-invoke f { } { } { } { } 0 0 "free" }
298 T{ ##slot-imm f 2 0 1 0 }
303 T{ ##slot-imm f 1 0 1 0 }
304 T{ ##alien-invoke f { } { } { } { } 0 0 "free" }
305 T{ ##slot-imm f 2 0 1 0 }
306 } test-alias-analysis
313 T{ ##set-slot-imm f 1 0 1 0 }
314 T{ ##alien-invoke f { } { } { } { } 0 0 "free" }
315 T{ ##slot-imm f 2 0 1 0 }
321 T{ ##set-slot-imm f 1 0 1 0 }
322 T{ ##alien-invoke f { } { } { } { } 0 0 "free" }
323 T{ ##slot-imm f 2 0 1 0 }
324 } test-alias-analysis
332 T{ ##set-slot-imm f 1 0 1 0 }
333 T{ ##alien-invoke f { } { } { } { } 0 0 "free" }
334 T{ ##set-slot-imm f 2 0 1 0 }
341 T{ ##set-slot-imm f 1 0 1 0 }
342 T{ ##alien-invoke f { } { } { } { } 0 0 "free" }
343 T{ ##set-slot-imm f 2 0 1 0 }
344 } test-alias-analysis
350 T{ ##slot-imm f 1 0 1 0 }
351 T{ ##alien-invoke f { } { } { } { } 0 0 "free" }
352 T{ ##set-slot-imm f 1 0 1 0 }
357 T{ ##slot-imm f 1 0 1 0 }
358 T{ ##alien-invoke f { } { } { } { } 0 0 "free" }
359 T{ ##set-slot-imm f 1 0 1 0 }
360 } test-alias-analysis
363 ! We can't eliminate stores on any alias class across a GC-ing
368 T{ ##slot-imm f 1 0 1 0 }
369 T{ ##alien-invoke f { } { } { } { } 0 0 "free" }
370 T{ ##copy f 2 1 any-rep }
375 T{ ##slot-imm f 1 0 1 0 }
376 T{ ##alien-invoke f { } { } { } { } 0 0 "free" }
377 T{ ##slot-imm f 2 0 1 0 }
378 } test-alias-analysis
385 T{ ##set-slot-imm f 1 0 1 0 }
386 T{ ##alien-invoke f { } { } { } { } 0 0 "free" }
387 T{ ##copy f 2 1 any-rep }
393 T{ ##set-slot-imm f 1 0 1 0 }
394 T{ ##alien-invoke f { } { } { } { } 0 0 "free" }
395 T{ ##slot-imm f 2 0 1 0 }
396 } test-alias-analysis
404 T{ ##set-slot-imm f 1 0 1 0 }
405 T{ ##alien-invoke f { } { } { } { } 0 0 "free" }
406 T{ ##set-slot-imm f 2 0 1 0 }
413 T{ ##set-slot-imm f 1 0 1 0 }
414 T{ ##alien-invoke f { } { } { } { } 0 0 "free" }
415 T{ ##set-slot-imm f 2 0 1 0 }
416 } test-alias-analysis
422 T{ ##slot-imm f 1 0 1 0 }
423 T{ ##alien-invoke f { } { } { } { } 0 0 "free" }
428 T{ ##slot-imm f 1 0 1 0 }
429 T{ ##alien-invoke f { } { } { } { } 0 0 "free" }
430 T{ ##set-slot-imm f 1 0 1 0 }
431 } test-alias-analysis
434 ! Make sure that gc-map-insns which are also vreg-insns are
439 T{ ##alien-indirect f { } { } { { 2 double-rep 0 } } { } 0 0 "free" }
440 T{ ##set-slot-imm f 2 0 1 0 }
445 T{ ##alien-indirect f { } { } { { 2 double-rep 0 } } { } 0 0 "free" }
446 T{ ##set-slot-imm f 2 0 1 0 }
447 } test-alias-analysis