Fix egregious sharing bug in LiberateCase
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.  



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