diff options
author | David Feuer <david.feuer@gmail.com> | 2017-03-01 13:47:39 -0500 |
---|---|---|
committer | David Feuer <David.Feuer@gmail.com> | 2017-03-01 13:47:41 -0500 |
commit | cbe569a56e2a82bb93a008beb56869d9a6a1d047 (patch) | |
tree | 4143ecfabf7b171159c2980e545fe66e0118e1f0 /compiler/vectorise | |
parent | 701256df88c61a2eee4cf00a59e61ef76a57b4b4 (diff) | |
download | haskell-cbe569a56e2a82bb93a008beb56869d9a6a1d047.tar.gz |
Upgrade UniqSet to a newtype
The fundamental problem with `type UniqSet = UniqFM` is that `UniqSet`
has a key invariant `UniqFM` does not. For example, `fmap` over
`UniqSet` will generally produce nonsense.
* Upgrade `UniqSet` from a type synonym to a newtype.
* Remove unused and shady `extendVarSet_C` and `addOneToUniqSet_C`.
* Use cached unique in `tyConsOfType` by replacing
`unitNameEnv (tyConName tc) tc` with `unitUniqSet tc`.
Reviewers: austin, hvr, goldfire, simonmar, niteria, bgamari
Reviewed By: niteria
Subscribers: thomie
Differential Revision: https://phabricator.haskell.org/D3146
Diffstat (limited to 'compiler/vectorise')
-rw-r--r-- | compiler/vectorise/Vectorise/Env.hs | 3 | ||||
-rw-r--r-- | compiler/vectorise/Vectorise/Type/Classify.hs | 10 |
2 files changed, 7 insertions, 6 deletions
diff --git a/compiler/vectorise/Vectorise/Env.hs b/compiler/vectorise/Vectorise/Env.hs index faaad69ba7..8f1a0a0662 100644 --- a/compiler/vectorise/Vectorise/Env.hs +++ b/compiler/vectorise/Vectorise/Env.hs @@ -31,6 +31,7 @@ import Name import NameEnv import FastString import UniqDFM +import UniqSet import Data.Maybe @@ -210,7 +211,7 @@ modVectInfo env mg_ids mg_tyCons vectDecls info , vectInfoTyCon = mk_env tyCons (global_tycons env) , vectInfoDataCon = mk_env dataCons (global_datacons env) , vectInfoParallelVars = (global_parallel_vars env `minusDVarSet` vectInfoParallelVars info) - `udfmIntersectUFM` (mkVarSet ids) + `udfmIntersectUFM` (getUniqSet $ mkVarSet ids) , vectInfoParallelTyCons = global_parallel_tycons env `minusNameSet` vectInfoParallelTyCons info } where diff --git a/compiler/vectorise/Vectorise/Type/Classify.hs b/compiler/vectorise/Vectorise/Type/Classify.hs index 98d9042482..a1215fd8c0 100644 --- a/compiler/vectorise/Vectorise/Type/Classify.hs +++ b/compiler/vectorise/Vectorise/Type/Classify.hs @@ -67,15 +67,15 @@ classifyTyCons convStatus parTyCons tcs = classify [] [] [] [] convStatus parTyC refs = ds `delListFromUniqSet` tcs -- the tycons that directly or indirectly depend on parallel arrays - tcs_par | anyUFM ((`elemNameSet` parTyCons) . tyConName) refs = tcs + tcs_par | uniqSetAny ((`elemNameSet` parTyCons) . tyConName) refs = tcs | otherwise = [] pts' = pts `extendNameSetList` map tyConName tcs_par - can_convert = (isNullUFM (filterUniqSet ((`elemNameSet` pts) . tyConName) (refs `minusUFM` cs)) + can_convert = (isEmptyUniqSet (filterUniqSet ((`elemNameSet` pts) . tyConName) (refs `uniqSetMinusUFM` cs)) && all convertable tcs) || isShowClass tcs - must_convert = anyUFM id (intersectUFM_C const cs refs) + must_convert = anyUFM id (intersectUFM_C const cs (getUniqSet refs)) && (not . isShowClass $ tcs) -- We currently admit Haskell 2011-style data and newtype declarations as well as type @@ -98,9 +98,9 @@ type TyConGroup = ([TyCon], UniqSet TyCon) tyConGroups :: [TyCon] -> [TyConGroup] tyConGroups tcs = map mk_grp (stronglyConnCompFromEdgedVerticesUniq edges) where - edges = [((tc, ds), tc, nonDetEltsUFM ds) | tc <- tcs + edges = [((tc, ds), tc, nonDetEltsUniqSet ds) | tc <- tcs , let ds = tyConsOfTyCon tc] - -- It's OK to use nonDetEltsUFM here as + -- It's OK to use nonDetEltsUniqSet here as -- stronglyConnCompFromEdgedVertices is still deterministic even -- if the edges are in nondeterministic order as explained in -- Note [Deterministic SCC] in Digraph. |