[project @ 1999-12-13 16:10:56 by simonmar]
[ghc-hetmet.git] / ghc / compiler / simplCore / SimplCore.lhs
index e3ab3d4..970838f 100644 (file)
@@ -259,6 +259,11 @@ simplifyPgm (imported_rule_ids, rule_lhs_fvs)
           let { (binds', counts') = initSmpl sw_chkr us1 imported_rule_ids 
                                              black_list_fn 
                                              (simplTopBinds tagged_binds);
+                       -- The imported_rule_ids are used by initSmpl to initialise
+                       -- the in-scope set.  That way, the simplifier will change any
+                       -- occurrences of the imported id to the one in the imported_rule_ids
+                       -- set, which are decorated with their rules.
+
                 all_counts        = counts `plusSimplCount` counts'
               } ;
 
@@ -283,11 +288,14 @@ simplifyPgm (imported_rule_ids, rule_lhs_fvs)
                -- Stop if we've run out of iterations
           if iteration_no == max_iterations then
                do {
+#ifdef DEBUG
                    if  max_iterations > 2 then
                            hPutStr stderr ("NOTE: Simplifier still going after " ++ 
                                    show max_iterations ++ 
                                    " iterations; bailing out.\n")
-                   else return ();
+                   else 
+#endif
+                       return ();
 
                    return ("Simplifier baled out", iteration_no, all_counts, binds')
                }
@@ -447,7 +455,14 @@ postSimplExpr (Let bind body)
     returnPM (Let bind' body')
 
 postSimplExpr (Note note body)
-  = postSimplExprEta body      `thenPM` \ body' ->
+  = postSimplExpr body         `thenPM` \ body' ->
+       -- Do *not* call postSimplExprEta here
+       -- We don't want to turn f = \x -> coerce t (\y -> f x y)
+       -- into                  f = \x -> coerce t (f x)
+       -- because then f has a lower arity.
+       -- This is not only bad in general, it causes the arity to 
+       -- not match the [Demand] on an Id, 
+       -- which confuses the importer of this module.
     returnPM (Note note body')
 
 postSimplExpr (Case scrut case_bndr alts)
@@ -500,8 +515,8 @@ otherwise, wrap with @addr2Integer@.
 litToRep (NoRepInteger i integer_ty)
   = returnPM (integer_ty, rhs)
   where
-    rhs | i > tARGET_MIN_INT &&                -- Small enough, so start from an Int
-         i < tARGET_MAX_INT
+    rhs | i >= tARGET_MIN_INT &&       -- Small enough, so start from an Int
+         i <= tARGET_MAX_INT
        = Con (DataCon smallIntegerDataCon) [Con (Literal (mkMachInt i)) []]
   
        | otherwise                     -- Big, so start from a string