[MLton-commit] r4370
Stephen Weeks
MLton@mlton.org
Fri, 3 Mar 2006 11:16:19 -0800
Fixed a bug in the SSA simplifier. Redundant tests didn't count the
start label of a function as an occurrence, and hence the in-degree of
the start block could be too low. This caused an incorrect
elimination of an irredundant test, in examples like the following.
fun f () = loop ()
loop ()
b: bool = WordR_equal (w1, w2)
case b of
true => loop | false => L_1
L_1 ()
return
The problem is that loop was marked as having in-degree one instead of
two, and hence the fact that w1=w2 was propagated to loop in the true
branch, which then causes the test to be redundant.
----------------------------------------------------------------------
U mlton/trunk/mlton/ssa/redundant-tests.fun
----------------------------------------------------------------------
Modified: mlton/trunk/mlton/ssa/redundant-tests.fun
===================================================================
--- mlton/trunk/mlton/ssa/redundant-tests.fun 2006-03-03 18:51:40 UTC (rev 4369)
+++ mlton/trunk/mlton/ssa/redundant-tests.fun 2006-03-03 19:16:18 UTC (rev 4370)
@@ -192,11 +192,12 @@
facts = ref [],
inDeg = ref 0}))
(* Set up inDeg. *)
+ fun inc l = Int.inc (#inDeg (labelInfo l))
+ val () = inc start
val _ =
Vector.foreach
(blocks, fn Block.T {transfer, ...} =>
- Transfer.foreachLabel
- (transfer, Int.inc o #inDeg o labelInfo))
+ Transfer.foreachLabel (transfer, inc))
(* Perform analysis, set up facts, and set up ancestor. *)
fun loop (Tree.T (Block.T {label, statements, transfer, ...},
children),