- Just pairs -> lookup_list pairs expr
-
-lookup_list :: [(CoreExpr,CoreExpr)] -> CoreExpr -> Maybe CoreExpr
-lookup_list [] expr = Nothing
-lookup_list ((e,e'):es) expr | cheapEqExpr e expr = Just e'
- | otherwise = lookup_list es expr
-
+ Just pairs -> lookup_list pairs
+ where
+ -- In this lookup we use full expression equality
+ -- Reason: when expressions differ we generally find out quickly
+ -- but I found that cheapEqExpr was saying (\x.x) /= (\y.y),
+ -- and this kind of thing happened in real programs
+ lookup_list :: [(CoreExpr,CoreExpr)] -> Maybe CoreExpr
+ lookup_list [] = Nothing
+ lookup_list ((e,e'):es) | eqExpr in_scope e expr = Just e'
+ | otherwise = lookup_list es
+
+addCSEnvItem :: CSEnv -> CoreExpr -> CoreExpr -> CSEnv