[turn case's of exactly 2 branches into 'if' statements. generalize unit-unit grin optimization
John Meacham <john@repetae.net>**20060128184304] hunk ./C/FromGrin.hs 227
+convertBody (Case v@(Var _ ty) [p1@(NodeC t _) :-> e1,p2 :-> e2]) | ty == TyNode = do
+    scrut <- convertVal v
+    let tag = project' anyTag scrut
+        da v@Var {} _ = do
+            v'' <- convertVal v
+            return $ assign v'' scrut
+        da (NodeC t as) e = do
+            as' <- mapM convertVal as
+            let tmp = project' (nodeStructName t) scrut
+                ass = mconcat [if needed a then assign  a' (project (arg i) tmp) else mempty | a' <- as' | a <- as | i <- [(1 :: Int) ..] ]
+                fve = freeVars e
+                needed (Var v _) = v `Set.member` fve
+            return ass
+        am | isVar p2 = id
+           | otherwise = annotate (show p2)
+    e1' <- convertBody e1
+    e2' <- convertBody e2
+    p1' <- da p1 e1
+    p2' <- liftM am $ da p2 e2
+    return $ profile_case_inc `mappend` cif (operator "==" (constant $ enum (nodeTagName t)) tag) (p1' `mappend` e1') (p2' `mappend` e2')
+
hunk ./C/FromGrin.hs 272
+        am | isVar p2 = id
+           | otherwise = annotate (show p2)
hunk ./C/FromGrin.hs 276
-    return $ profile_case_inc `mappend` cif (operator "==" (cp p1) scrut') e1' e2'
+    return $ profile_case_inc `mappend` cif (operator "==" (cp p1) scrut') e1' (am e2')
hunk ./C/FromGrin.hs 384
+isVar Var {} = True
+isVar _ = False
+
hunk ./C/Generate.hs 2
+    Annotate(..),
hunk ./Grin/Simplify.hs 264
-    f (e :>>= Tup [] :-> Return (Tup []) :>>= lr) = do
+    f (e :>>= v1 :-> Return v2 :>>= lr) | v1 == v2 = do
hunk ./Grin/Simplify.hs 267
-    f (e :>>= Tup [] :-> Return (Tup [])) = do
+    f (e :>>= v1 :-> Return v2) | v1 == v2 = do
hunk ./Grin/Simplify.hs 444
+{-# NOINLINE simplify #-}
+