[commit: ghc] wip/T12364: Do not optimize UData [[Abs], [Abs]] to UHead (83995cb)

git at git.haskell.org git at git.haskell.org
Tue Jul 5 08:29:37 UTC 2016


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

On branch  : wip/T12364
Link       : http://ghc.haskell.org/trac/ghc/changeset/83995cb2e1d0e7125cb10d4202ad26da6541a042/ghc

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

commit 83995cb2e1d0e7125cb10d4202ad26da6541a042
Author: Joachim Breitner <mail at joachim-breitner.de>
Date:   Tue Jul 5 10:33:09 2016 +0200

    Do not optimize UData [[Abs],[Abs]] to UHead
    
    as the "constructor tag" is, in a way, a used component.


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

83995cb2e1d0e7125cb10d4202ad26da6541a042
 compiler/basicTypes/Demand.hs | 9 ++++++---
 1 file changed, 6 insertions(+), 3 deletions(-)

diff --git a/compiler/basicTypes/Demand.hs b/compiler/basicTypes/Demand.hs
index 07fb39a..3ee02f1 100644
--- a/compiler/basicTypes/Demand.hs
+++ b/compiler/basicTypes/Demand.hs
@@ -389,9 +389,12 @@ mkUCall :: Count -> UseDmd -> UseDmd
 mkUCall c a  = UCall c a
 
 mkUData :: [[ArgUse]] -> UseDmd
-mkUData ux
-  | all (all (== Abs)) ux = UHead
-  | otherwise             = UData ux
+mkUData [ux] | all (== Abs) ux = UHead
+  -- Sum types are not UHead (which is assumed to be the demand type of a seq),
+  -- As although the components may possibly not be used, the information _which_
+  -- constructor is used is important.
+mkUData uss | all null uss     = Used
+mkUData uss                    = UData uss
 
 lubCount :: Count -> Count -> Count
 lubCount _ Many = Many



More information about the ghc-commits mailing list