Fix egregious sharing bug in LiberateCase
authorsimonpj@microsoft.com <unknown>
Wed, 20 Jun 2007 07:56:48 +0000 (07:56 +0000)
committersimonpj@microsoft.com <unknown>
Wed, 20 Jun 2007 07:56:48 +0000 (07:56 +0000)
commitda5b25fee9f8da8768e268b52c829abe3c76a3c7
tree2fed6d531b131c52663974669dda4b9b6de8c11f
parentd363c1fc28d8227b27b4506ebeb089845c5b0af6
Fix egregious sharing bug in LiberateCase

Andy Gill writes: consider the following code

       f = g (case v of
                V a b -> a : t f)

where g is expensive. Liberate case will turn this into

       f = g (case v of
               V a b -> a : t (letrec f = g (case v of
                                             V a b -> a : f t)
                                in f)
             )
Yikes! We evaluate g twice. This leads to a O(2^n) explosion
if g calls back to the same code recursively.

This may be the same as Trac #1366.
compiler/simplCore/LiberateCase.lhs