Re[2]: Common subexpression elemination (CSE)

2006-11-29 Thread Bulat Ziganshin
Hello Dinko, Wednesday, November 29, 2006, 11:56:49 AM, you wrote: >> How exactly can CSE cause space leaks, and what does this have to do >> with strictness? standard example is x = [1..9] ++ [1..9] comparing to x = a++a where a=[1..9] first version runs (without CSE transformation) in fixed

Re: Common subexpression elemination (CSE)

2006-11-29 Thread Ulf Norell
On Nov 28, 2006, at 10:34 AM, Dinko Tenev wrote: How exactly can CSE cause space leaks, and what does this have to do with strictness? See this message for a nice example: http://www.haskell.org/pipermail/haskell-cafe/2003-June/004484.html / Ulf

Re: Common subexpression elemination (CSE)

2006-11-29 Thread Dinko Tenev
On 11/28/06, Mark T.B. Carroll <[EMAIL PROTECTED]> wrote: "Dinko Tenev" <[EMAIL PROTECTED]> writes: (snip) > How exactly can CSE cause space leaks, and what does this have to do > with strictness? I puzzled over Lennart's comment too, and the theory I formed was that you might have the same exp

Re: Common subexpression elemination (CSE)

2006-11-28 Thread Lennart Augustsson
The relation to strictness is that you have much tighter control over when things are evaluated (typically) for something strict, so it is less likely to leak. Take the expression 'e + e' at some base type. It's harmless to CSE this to 'let x = e in x+x' because + is strict in x. Whereas '(

Re: Common subexpression elemination (CSE)

2006-11-28 Thread Dinko Tenev
On 11/28/06, Bertram Felgenhauer <[EMAIL PROTECTED]> wrote: Dinko Tenev wrote: > On 11/27/06, Lennart Augustsson <[EMAIL PROTECTED]> wrote: > > > >GHC doesn't normally do CSE. CSE can cause space leaks, so you can't > >do it willy-nilly. > >I'm sure there are some strict contexts where it could

Re: Common subexpression elemination (CSE)

2006-11-28 Thread Bertram Felgenhauer
Dinko Tenev wrote: > On 11/27/06, Lennart Augustsson <[EMAIL PROTECTED]> wrote: > > > >GHC doesn't normally do CSE. CSE can cause space leaks, so you can't > >do it willy-nilly. > >I'm sure there are some strict contexts where it could be done > >safely, but I don't think ghc uses that information

Re: Common subexpression elemination (CSE)

2006-11-28 Thread Dinko Tenev
On 11/27/06, Lennart Augustsson <[EMAIL PROTECTED]> wrote: GHC doesn't normally do CSE. CSE can cause space leaks, so you can't do it willy-nilly. I'm sure there are some strict contexts where it could be done safely, but I don't think ghc uses that information (yet). -- Lennart My

RE: Common subexpression elemination (CSE)

2006-11-27 Thread Simon Peyton-Jones
mber 2006 13:40 | To: Christian Maeder | Cc: GHC Users Mailing List | Subject: Re: Common subexpression elemination (CSE) | | GHC doesn't normally do CSE. CSE can cause space leaks, so you can't | do it willy-nilly. | I'm sure there are some strict contexts where it could be done | safe

Re: Common subexpression elemination (CSE)

2006-11-27 Thread Christian Maeder
Lennart Augustsson schrieb: > GHC doesn't normally do CSE. CSE can cause space leaks, so you can't do > it willy-nilly. > I'm sure there are some strict contexts where it could be done safely, > but I don't think ghc uses that information (yet). Interestingly, it can only be switched off by -fno-

Re: Common subexpression elemination (CSE)

2006-11-27 Thread Lennart Augustsson
GHC doesn't normally do CSE. CSE can cause space leaks, so you can't do it willy-nilly. I'm sure there are some strict contexts where it could be done safely, but I don't think ghc uses that information (yet). -- Lennart On Nov 27, 2006, at 08:34 , Christian Maeder wrote: the foll

Common subexpression elemination (CSE)

2006-11-27 Thread Christian Maeder
the following code does not run as fast as expected: modexp a e n = if e <= 0 then 1 else if even e then mod (modexp a (div e 2) n * modexp a (div e 2) n) n else mod (a * modexp a (e - 1) n) n it gets only fast if written as: modexp2 a e n = if e <= 0 then 1 else if even e then le