[commit: ghc] master: Use isFamFreeTyCon now we have it (e912310)

git at git.haskell.org git at git.haskell.org
Mon Dec 5 17:40:33 UTC 2016


Repository : ssh://git@git.haskell.org/ghc

On branch  : master
Link       : http://ghc.haskell.org/trac/ghc/changeset/e912310206e86169c920319f587d310c8b9cafe0/ghc

>---------------------------------------------------------------

commit e912310206e86169c920319f587d310c8b9cafe0
Author: Simon Peyton Jones <simonpj at microsoft.com>
Date:   Mon Dec 5 13:50:48 2016 +0000

    Use isFamFreeTyCon now we have it
    
    Refactoring only


>---------------------------------------------------------------

e912310206e86169c920319f587d310c8b9cafe0
 compiler/typecheck/TcFlatten.hs     | 12 ++++--------
 compiler/types/TyCon.hs             |  2 +-
 testsuite/tests/perf/compiler/all.T |  4 +++-
 3 files changed, 8 insertions(+), 10 deletions(-)

diff --git a/compiler/typecheck/TcFlatten.hs b/compiler/typecheck/TcFlatten.hs
index 94fdfb8..700412b 100644
--- a/compiler/typecheck/TcFlatten.hs
+++ b/compiler/typecheck/TcFlatten.hs
@@ -19,7 +19,6 @@ import TyCoRep   -- performs delicate algorithm on types
 import Coercion
 import Var
 import VarEnv
-import NameEnv
 import Outputable
 import TcSMonad as TcS
 import BasicTypes( SwapFlag(..) )
@@ -895,19 +894,16 @@ flatten_one (AppTy ty1 ty2)
                                    role2 co2 xi2 ty2
                                    role1 ) }  -- output should match fmode
 
-flatten_one ty@(TyConApp tc tys)
+flatten_one (TyConApp tc tys)
   -- Expand type synonyms that mention type families
   -- on the RHS; see Note [Flattening synonyms]
   | Just (tenv, rhs, tys') <- expandSynTyCon_maybe tc tys
   , let expanded_ty = mkAppTys (substTy (mkTvSubstPrs tenv) rhs) tys'
   = do { mode <- getMode
-       ; let used_tcs = tyConsOfType rhs
        ; case mode of
-           FM_FlattenAll | anyNameEnv isTypeFamilyTyCon used_tcs
-                         -> do { traceFlat "flatten_one syn expand" (ppr ty $$ ppr used_tcs)
-                               ; flatten_one expanded_ty }
-           _             -> do { traceFlat "flatten_one syn no expand" (ppr ty)
-                               ; flatten_ty_con_app tc tys } }
+           FM_FlattenAll | not (isFamFreeTyCon tc)
+                         -> flatten_one expanded_ty
+           _             -> flatten_ty_con_app tc tys }
 
   -- Otherwise, it's a type function application, and we have to
   -- flatten it away as well, and generate a new given equality constraint
diff --git a/compiler/types/TyCon.hs b/compiler/types/TyCon.hs
index ebb18f0..ec2f5d5 100644
--- a/compiler/types/TyCon.hs
+++ b/compiler/types/TyCon.hs
@@ -627,7 +627,7 @@ data TyCon
         synIsTau     :: Bool,   -- True <=> the RHS of this synonym does not
                                  --          have any foralls, after expanding any
                                  --          nested synonyms
-        synIsFamFree  :: Bool    -- True <=> the RHS of this synonym does mention
+        synIsFamFree  :: Bool    -- True <=> the RHS of this synonym does not mention
                                  --          any type synonym families (data families
                                  --          are fine), again after expanding any
                                  --          nested synonyms
diff --git a/testsuite/tests/perf/compiler/all.T b/testsuite/tests/perf/compiler/all.T
index 7ce6562..0ccde15 100644
--- a/testsuite/tests/perf/compiler/all.T
+++ b/testsuite/tests/perf/compiler/all.T
@@ -767,7 +767,7 @@ test('T9872c',
 test('T9872d',
      [ only_ways(['normal']),
        compiler_stats_num_field('bytes allocated',
-          [(wordsize(64), 506691240, 5),
+          [(wordsize(64), 478169352, 5),
           # 2014-12-18    796071864   Initally created
           # 2014-12-18    739189056   Reduce type families even more eagerly
           # 2015-01-07    687562440   TrieMap leaf compression
@@ -775,6 +775,8 @@ test('T9872d',
           # 2015-12-11    566134504   TypeInType; see #11196
           # 2016-02-08    534693648   Improved a bit by tyConRolesRepresentational
           # 2016-03-18    506691240   optimize Unify & zonking
+          # 2016-12-05    478169352   using tyConIsTyFamFree, I think, but only
+          #                           a 1% improvement 482 -> 478
            (wordsize(32), 264566040, 5)
           # some date     328810212
           # 2015-07-11    350369584



More information about the ghc-commits mailing list