id	summary	reporter	owner	description	type	status	priority	milestone	component	version	resolution	keywords	cc	os	architecture	failure	difficulty	testcase	blockedby	blocking	related
5075	CPR optimisation for sum types if only one constructor is used	batterseapower	simonpj	"Inspired by #3138, it might be useful for StrAnal to detect functions such as the following where only one of the data constructors for a sum type are CPRed:

{{{
loop x = case x < 10 of True -> Left x; False -> loop (x*2)
}}}

We can usefully transform to:

{{{
$wloop x = case (case x < 10 of True -> Left x; False -> loop (x*2)) of Left y -> (# y #)
loop x = case loop x of (# y #) -> Left y
}}}

Attached patch implements this behaviour. Most of the complication in the new code occurs because adding a DataCon field to the Demand data type means that we have to define a separate IfaceDemand type for storage in interface files.

The patch validates but I haven't done any tests on nofib. I have confirmed that the new optimisation hits on some examples, though."	feature request	new	normal	7.6.2	Compiler	7.0.3			tkn.akio@… danielv@… nfrisby@…	Unknown/Multiple	Unknown/Multiple	None/Unknown	Unknown				
