RE: Common subexpressions are not optimized to single one?

2003-12-09 Thread Simon Marlow
I'm wondering about the optimization of ghc. I thought that since functions are pure in haskell, compiler can/do factorize common subexpressions when it optimizes a code. But the result of the following experiment looks negative; g 10 100 is caluculated twice. Am I missing something?

Re: Common subexpressions are not optimized to single one?

2003-12-03 Thread Koji Nakahara
My original mail might be misleading, but I didn't mean that I want to rely on the optimization to make the program work. I just thought If I could expect such an optimization to be performed, I would not need to rewrite everytime func (g x) (g x) -- g x = unsafeperformIO $ do {...} to let h =

Re: Common subexpressions are not optimized to single one?

2003-12-02 Thread ajb
G'day all. Quoting Koji Nakahara [EMAIL PROTECTED]: I'm wondering about the optimization of ghc. I thought that since functions are pure in haskell, compiler can/do factorize common subexpressions when it optimizes a code. The short answer is no. While the optimisation preserves semantics,

Re: Common subexpressions are not optimized to single one?

2003-12-02 Thread Derek Elkins
On Wed, 3 Dec 2003 03:29:14 +0900 Koji Nakahara [EMAIL PROTECTED] wrote: I want to use some C functions from haskell each of which is not pure but the result of their sequential combination is pure. I'm planning to write some functions like g above(but more complex and actually pure) and