[project @ 2001-08-23 07:13:16 by simonpj] ------------------------------ 	Improve the demand analyser [case] 	------------------------------
[project @ 2001-08-23 07:13:16 by simonpj]
------------------------------
	Improve the demand analyser [case]
	------------------------------

1. In the Case case of dmdAnal, I dealt with the case binder in a way that
was both clumsy and pessimistic.  This commit fixes that:

	-- Figure out whether the demand on the case binder is used, and use
	-- that to set the scrut_dmd.  This is utterly essential.
	-- Consider	f x = case x of y { (a,b) -> k y a }
	-- If we just take scrut_demand = U(L,A), then we won't pass x to the
	-- worker, so the worker will rebuild
	--	x = (a, absent-error)
	-- and that'll crash.
	-- So at one stage I had:
	--	dead_case_bndr		 = isAbsentDmd (idNewDemandInfo case_bndr')
	--	keepity | dead_case_bndr = Drop
	--		| otherwise	 = Keep
	--
	-- But then consider
	--	case x of y { (a,b) -> h y + a }
	-- where h : U(LL) -> T
	-- The above code would compute a Keep for x, since y is not Abs, which is silly
	-- The insight is, of course, that a demand on y is a demand on the
	-- scrutinee, so we need to `both` it with the scrut demand

        scrut_dmd 		 = Seq Drop Now [idNewDemandInfo b | b <- bndrs', isId b]
				   `both`
				   idNewDemandInfo case_bndr'

	-- There used to be a special case for when
	--	ty == TyVarTy tv
	-- (a not-uncommon case) in which case the substitution was dropped.
	-- But the type-tidier changes the print-name of a type variable without
	-- changing the unique, and that led to a bug.   Why?  Pre-tidying, we had
	-- a type {Foo t}, where Foo is a one-method class.  So Foo is really a newtype.
	-- And it happened that t was the type variable of the class.  Post-tiding,


2. 'defer' can be simplified to 'lub Abs', reducing the number of places
where things can go wrong.

3. Add comments

ezyang/ghc,da-x/ghc,urbanslug/ghc,mcmaniac/ghc,spacekitteh/smcghc,tjakway/ghcjvm,snoyberg/ghc,vTurbine/ghc,AlexanderPankiv/ghc,oldmanmike/ghc,ekmett/ghc,snoyberg/ghc,ghc-android/ghc,bitemyapp/ghc,spacekitteh/smcghc,oldmanmike/ghc,snoyberg/ghc,mettekou/ghc,GaloisInc/halvm-ghc,siddhanathan/ghc,gridaphobe/ghc,ezyang/ghc,holzensp/ghc,nushio3/ghc,vTurbine/ghc,sgillespie/ghc,da-x/ghc,anton-dessiatov/ghc,shlevy/ghc,ml9951/ghc,ryantm/ghc,sdiehl/ghc,siddhanathan/ghc,siddhanathan/ghc,urbanslug/ghc,mettekou/ghc,nathyong/microghc-ghc,TomMD/ghc,ml9951/ghc,tjakway/ghcjvm,TomMD/ghc,ml9951/ghc,forked-upstream-packages-for-ghcjs/ghc,lukexi/ghc,fmthoma/ghc,frantisekfarka/ghc-dsi,nkaretnikov/ghc,siddhanathan/ghc,frantisekfarka/ghc-dsi,nathyong/microghc-ghc,forked-upstream-packages-for-ghcjs/ghc,hferreiro/replay,ekmett/ghc,GaloisInc/halvm-ghc,sgillespie/ghc,wxwxwwxxx/ghc,vikraman/ghc,ghc-android/ghc,hferreiro/replay,green-haskell/ghc,christiaanb/ghc,snoyberg/ghc,forked-upstream-packages-for-ghcjs/ghc,ghc-android/ghc,lukexi/ghc,vTurbine/ghc,gridaphobe/ghc,christiaanb/ghc,AlexanderPankiv/ghc,forked-upstream-packages-for-ghcjs/ghc,da-x/ghc,ilyasergey/GHC-XAppFix,nomeata/ghc,mfine/ghc,jstolarek/ghc,mcschroeder/ghc,urbanslug/ghc,christiaanb/ghc,vikraman/ghc,ghc-android/ghc,nkaretnikov/ghc,TomMD/ghc,holzensp/ghc,mcschroeder/ghc,vTurbine/ghc,ezyang/ghc,mcschroeder/ghc,mfine/ghc,fmthoma/ghc,mcmaniac/ghc,AlexanderPankiv/ghc,frantisekfarka/ghc-dsi,gridaphobe/ghc,da-x/ghc,sdiehl/ghc,nushio3/ghc,mcmaniac/ghc,ryantm/ghc,spacekitteh/smcghc,christiaanb/ghc,tibbe/ghc,vTurbine/ghc,urbanslug/ghc,ezyang/ghc,nathyong/microghc-ghc,anton-dessiatov/ghc,anton-dessiatov/ghc,vikraman/ghc,spacekitteh/smcghc,anton-dessiatov/ghc,bitemyapp/ghc,olsner/ghc,nushio3/ghc,oldmanmike/ghc,olsner/ghc,GaloisInc/halvm-ghc,elieux/ghc,wxwxwwxxx/ghc,tjakway/ghcjvm,siddhanathan/ghc,AlexanderPankiv/ghc,bitemyapp/ghc,ml9951/ghc,tibbe/ghc,sdiehl/ghc,elieux/ghc,ekmett/ghc,mfine/ghc,TomMD/ghc,christiaanb/ghc,nathyong/microghc-ghc,jstolarek/ghc,sgillespie/ghc,nomeata/ghc,mfine/ghc,sgillespie/ghc,nomeata/ghc,mettekou/ghc,mcschroeder/ghc,mfine/ghc,fmthoma/ghc,acowley/ghc,olsner/ghc,snoyberg/ghc,hferreiro/replay,wxwxwwxxx/ghc,hferreiro/replay,mfine/ghc,lukexi/ghc-7.8-arm64,holzensp/ghc,shlevy/ghc,ml9951/ghc,nushio3/ghc,olsner/ghc,shlevy/ghc,mcschroeder/ghc,acowley/ghc,vikraman/ghc,mcschroeder/ghc,vikraman/ghc,nushio3/ghc,frantisekfarka/ghc-dsi,elieux/ghc,ezyang/ghc,oldmanmike/ghc,GaloisInc/halvm-ghc,nushio3/ghc,nomeata/ghc,mcschroeder/ghc,GaloisInc/halvm-ghc,sdiehl/ghc,green-haskell/ghc,siddhanathan/ghc,gridaphobe/ghc,ilyasergey/GHC-XAppFix,nathyong/microghc-ghc,elieux/ghc,ghc-android/ghc,gridaphobe/ghc,oldmanmike/ghc,gcampax/ghc,christiaanb/ghc,urbanslug/ghc,nomeata/ghc,tibbe/ghc,lukexi/ghc-7.8-arm64,ml9951/ghc,sgillespie/ghc,lukexi/ghc-7.8-arm64,AlexanderPankiv/ghc,da-x/ghc,nathyong/microghc-ghc,hferreiro/replay,mettekou/ghc,elieux/ghc,ghc-android/ghc,AlexanderPankiv/ghc,spacekitteh/smcghc,elieux/ghc,anton-dessiatov/ghc,fmthoma/ghc,oldmanmike/ghc,oldmanmike/ghc,vikraman/ghc,gcampax/ghc,TomMD/ghc,ml9951/ghc,anton-dessiatov/ghc,mettekou/ghc,TomMD/ghc,urbanslug/ghc,lukexi/ghc-7.8-arm64,AlexanderPankiv/ghc,fmthoma/ghc,GaloisInc/halvm-ghc,vikraman/ghc,tjakway/ghcjvm,wxwxwwxxx/ghc,gcampax/ghc,acowley/ghc,gcampax/ghc,ryantm/ghc,fmthoma/ghc,wxwxwwxxx/ghc,lukexi/ghc,gridaphobe/ghc,urbanslug/ghc,nkaretnikov/ghc,nkaretnikov/ghc,gridaphobe/ghc,christiaanb/ghc,fmthoma/ghc,jstolarek/ghc,shlevy/ghc,mcmaniac/ghc,ilyasergey/GHC-XAppFix,lukexi/ghc,forked-upstream-packages-for-ghcjs/ghc,mettekou/ghc,snoyberg/ghc,acowley/ghc,da-x/ghc,lukexi/ghc,nkaretnikov/ghc,shlevy/ghc,forked-upstream-packages-for-ghcjs/ghc,forked-upstream-packages-for-ghcjs/ghc,ezyang/ghc,nathyong/microghc-ghc,holzensp/ghc,tjakway/ghcjvm,gcampax/ghc,GaloisInc/halvm-ghc,ghc-android/ghc,ryantm/ghc,lukexi/ghc-7.8-arm64,wxwxwwxxx/ghc,holzensp/ghc,TomMD/ghc,tibbe/ghc,sgillespie/ghc,sdiehl/ghc,ryantm/ghc,olsner/ghc,da-x/ghc,ml9951/ghc,sgillespie/ghc,ezyang/ghc,tjakway/ghcjvm,frantisekfarka/ghc-dsi,wxwxwwxxx/ghc,jstolarek/ghc,green-haskell/ghc,hferreiro/replay,jstolarek/ghc,ekmett/ghc,hferreiro/replay,acowley/ghc,shlevy/ghc,anton-dessiatov/ghc,shlevy/ghc,acowley/ghc,green-haskell/ghc,olsner/ghc,gcampax/ghc,mcmaniac/ghc,snoyberg/ghc,sdiehl/ghc,tjakway/ghcjvm,tibbe/ghc,elieux/ghc,vTurbine/ghc,ilyasergey/GHC-XAppFix,siddhanathan/ghc,bitemyapp/ghc,olsner/ghc,sdiehl/ghc,nkaretnikov/ghc,nkaretnikov/ghc,ekmett/ghc,mfine/ghc,mettekou/ghc,vTurbine/ghc,nushio3/ghc,gcampax/ghc,acowley/ghc,green-haskell/ghc,bitemyapp/ghc