Do not be overzealous with inlining results of polymorphic functions
authorchristiaanb <christiaan.baaij@gmail.com>
Tue, 8 Jun 2010 13:45:14 +0000 (15:45 +0200)
committerchristiaanb <christiaan.baaij@gmail.com>
Tue, 8 Jun 2010 13:45:14 +0000 (15:45 +0200)
clash/CLasH/Normalize.hs

index 4ce4ffa53b4b189b4f7983968f5aac0a18c47ad8..a70829ade05370f51d66c9dbe0575e8e124ef97c 100644 (file)
@@ -753,7 +753,7 @@ inlinenonrepresult :: Transform
 -- that is fully applied (i.e., dos not have a function type) but is not
 -- representable. We apply in any context, since non-representable
 -- expressions are generally left alone and can occur anywhere.
 -- that is fully applied (i.e., dos not have a function type) but is not
 -- representable. We apply in any context, since non-representable
 -- expressions are generally left alone and can occur anywhere.
-inlinenonrepresult context expr | not (is_fun expr) =
+inlinenonrepresult context expr | not (is_applicable expr) && not (has_free_tyvars expr) =
   case collectArgs expr of
     (Var f, args) | not (Id.isDictId f) -> do
       repr <- isRepr expr
   case collectArgs expr of
     (Var f, args) | not (Id.isDictId f) -> do
       repr <- isRepr expr
@@ -952,7 +952,7 @@ letmerge c expr = return expr
 -- What transforms to run?
 transforms = [ ("inlinedict", inlinedict)
              , ("inlinetoplevel", inlinetoplevel)
 -- What transforms to run?
 transforms = [ ("inlinedict", inlinedict)
              , ("inlinetoplevel", inlinetoplevel)
-             -- , ("inlinenonrepresult", inlinenonrepresult)
+             , ("inlinenonrepresult", inlinenonrepresult)
              , ("knowncase", knowncase)
              , ("classopresolution", classopresolution)
              , ("argprop", argprop)
              , ("knowncase", knowncase)
              , ("classopresolution", classopresolution)
              , ("argprop", argprop)