[fully switch to new dead code elimination algorithm
John Meacham <john@repetae.net>**20060126050104] hunk ./Grin/DeadCode.hs 56
-        if not u then tick stats "Optimize.dead-code.func" >> return [] else do
+        if not u then tick stats ("Optimize.dead-code.func.{" ++ show x) >> return [] else do
hunk ./Grin/DeadCode.hs 74
-        let useVar v | v < v0 = addRule $ fn' `implies` sValue usedCafs v
-            useVar v = addRule $ fn' `implies` sValue usedVars v
-            varValue v | v < v0 = sValue usedCafs v
+        let varValue v | v < v0 = sValue usedCafs v
hunk ./Grin/DeadCode.hs 77
-            g (App a [e] _) | a == funcEval =  mapM_ useVar (freeVars e)
-            g (App a [x,y] _) | a == funcApply =  mapM_ useVar (freeVars (x,y))
-            g (Case e _) =  mapM_ useVar (freeVars e)
-            g Prim { expArgs = as } = mapM_ useVar (freeVars as)
+            g (App a [e] _) | a == funcEval =  addRule (doNode e)
+            g (App a [x,y] _) | a == funcApply =  addRule (doNode x `mappend` doNode y)
+            g (Case e _) =  addRule (doNode e)
+            g Prim { expArgs = as } = addRule (mconcatMap doNode as)
hunk ./Grin/DeadCode.hs 84
-            g (Update ~(Var v _) n@(NodeC x vs))
+                addRule (mconcatMap doConst vs)
+            g (Update (Var v _) n@(~(NodeC x vs)))
hunk ./Grin/DeadCode.hs 91
-            g x@Fetch {} = mapM_ useVar (freeVars x)
+            g (Fetch x) = addRule $ doNode x
+            g (Cast x _) = addRule $ doNode x
hunk ./Grin/DeadCode.hs 96
+            g x = error $ "deadcode.g: " ++ show x
hunk ./Grin/DeadCode.hs 100
-            h (p,Fetch v) = addRule $ mconcat $ [ mconcatMap (implies (varValue pv) . varValue) (freeVars v) | pv <- freeVars p]
+            h (p,Fetch v) = addRule $ mconcat $ [ conditionalRule id  (varValue pv) (doNode v) | pv <- freeVars p]
+            h (p,Cast v _) = addRule $ mconcat $ [ conditionalRule id  (varValue pv) (doNode v) | pv <- freeVars p]
+            --h (p,Fetch v) = addRule $ mconcat $ [ mconcatMap (implies (varValue pv) . varValue) (freeVars v) | pv <- freeVars p]
+            --h (p,Cast v _) = addRule $ mconcat $ [ mconcatMap (implies (varValue pv) . varValue) (freeVars v) | pv <- freeVars p]
hunk ./Grin/DeadCode.hs 105
-            doNode (NodeC n as) | not postInline, Just (x,fn) <- tagUnfunction n  = mconcat $ implies fn' (sValue usedFuncs fn):[ mconcatMap (implies (sValue usedArgs fn) . varValue) (freeVars a) | (fn,a) <- combineArgs fn as]
-            doNode x = mconcatMap (implies fn' . varValue) (freeVars x)
+            doNode (NodeC n as) | not postInline, Just (x,fn) <- tagUnfunction n  = mappend (mconcatMap doConst as) $ mconcat (implies fn' (sValue usedFuncs fn):[ mconcatMap (implies (sValue usedArgs fn) . varValue) (freeVars a) | (fn,a) <- combineArgs fn as])
+            doNode x = doConst x `mappend` mconcatMap (implies fn' . varValue) (freeVars x)
+            doConst _ | postInline  = mempty
+            doConst (Const n) = doNode n
+            doConst (Tup ns) = mconcatMap doConst ns
+            doConst (NodeC n as) = mconcatMap doConst as
+            doConst (NodeV n as) = mconcatMap doConst as
+            doConst _ = mempty
hunk ./Grin/PointsToAnalysis.hs 19
+import Fixer.Supply
hunk ./Grin/PointsToAnalysis.hs 523
-    funcMap <- cmap (funcEq eq)
hunk ./Grin/PointsToAnalysis.hs 524
+    --funcMap <- cmap (funcEq eq)
hunk ./Grin/PointsToAnalysis.hs 526
+    funcSupply <- newSupply fr
+    funcMap <- do
+        vs <- flip mapM (funcEq eq) $ \ (v,p) -> do
+            x <- supplyValue funcSupply v
+            return (v,(x,p))
+        return $ Map.fromList vs
hunk ./Grin/PointsToAnalysis.hs 565
-                        addRule $ mconcatMap (self `evaledSuperSetOf`) (fsts [ runIdentity $ Map.lookup (tagFlipFunction n) funcMap | n <- (Set.toList $ getNodes p), tagIsSuspFunction n ])
+                        addRule $ mconcatMap (self `evaledSuperSetOf`) [ sValue funcSupply (tagFlipFunction n) | n <- (Set.toList $ getNodes p), tagIsSuspFunction n ]
hunk ./Grin/PointsToAnalysis.hs 596
-                            Just (1,fn) -> addRule $ self `isSuperSetOf` (fst $ runIdentity $ Map.lookup fn funcMap)
+                            Just (1,fn) -> addRule $ self `isSuperSetOf` sValue funcSupply fn
hunk ./Grin/PointsToAnalysis.hs 649
-                        mconcatMap (e' `isSuperSetOf`) (fsts [ runIdentity $ Map.lookup (tagFlipFunction n) funcMap | n <- (Set.toList $ getNodes e), tagIsSuspFunction n ])
+                        mconcatMap (e' `isSuperSetOf`) [ sValue funcSupply (tagFlipFunction n) | n <- (Set.toList $ getNodes e), tagIsSuspFunction n ]
hunk ./Grin/PointsToAnalysis.hs 664
-        simplePos (Func v) = case Map.lookup v funcMap of
-            Just (x,_) -> return x
-            Nothing -> error "funcMap has no var"
+        simplePos (Func v) = return $ sValue funcSupply v
hunk ./Grin/Simplify.hs 44
+at_OptSimplifyConstUpdate  = toAtom "Optimize.simplify.const-update"
hunk ./Grin/Simplify.hs 70
+    gs (Update Const {} Var {}) = do
+        lift $ tick stats at_OptSimplifyConstUpdate
+        gs (Return unit)
hunk ./Main.hs 43
-import Grin.DeadFunctions
hunk ./Main.hs 440
-        deadFunctions stats' [funcMain] x
-        x <- deadCode stats' [funcMain] x  -- XXX
+        --deadFunctions stats' [funcMain] x
hunk ./Main.hs 442
+        wdump FD.Steps $ printGrin x
+        x <- deadCode stats' [funcMain] x  -- XXX
hunk ./Main.hs 448
+