RE: [Haskell-cafe] Top-level TVars

On 14 December 2005 10:11, Joel Reymont wrote:
I'm a bit lost in the discussion. Why do I need -fno-cse and how do I seq at the top-level?
On Dec 14, 2005, at 10:05 AM, Tomasz Zielonka wrote:
On Wed, Dec 14, 2005 at 10:03:42AM -0000, Simon Marlow wrote:
Well sure, but it's only a temporary problem. And you also have to tell them to use {-# NOINLINE #-} and -fno-cse :-)
-fno-cse is also neccesary? Oops, I didn't know that. Can I simply place it in {-# OPTIONS -fno-cse #-} ?
Suppose you create two top-level IORefs with the same type, like this: var1 = unsafePerformIO $ newIORef 0 var2 = unsafePerformIO $ newIORef 0 GHC's CSE optimisation will common these up - after all, it's the same expression, so it must yield the same result, right? To turn this off, we use -fno-cse. It's good practice to use -fno-cse whenever you use top-level mutable objects of any kind. You can put it in the source file: {-# OPTIONS_GHC -fno-cse #-} at the top of your file. Cheers, Simon

On Wed, Dec 14, 2005 at 02:17:17PM -0000, Simon Marlow wrote:
Suppose you create two top-level IORefs with the same type, like this:
var1 = unsafePerformIO $ newIORef 0 var2 = unsafePerformIO $ newIORef 0
GHC's CSE optimisation will common these up - after all, it's the same expression, so it must yield the same result, right?
Ah, yes. Thanks for explanation.
To turn this off, we use -fno-cse. It's good practice to use -fno-cse whenever you use top-level mutable objects of any kind. You can put it in the source file:
{-# OPTIONS_GHC -fno-cse #-}
at the top of your file.
How about a new pragma: {-# OPTIMIZER_HANDS_OFF var1 #-} ;-) Best regards Tomasz -- I am searching for a programmer who is good at least in some of [Haskell, ML, C++, Linux, FreeBSD, math] for work in Warsaw, Poland

On Wed, Dec 14, 2005 at 02:17:17PM -0000, Simon Marlow wrote:
Suppose you create two top-level IORefs with the same type, like this:
var1 = unsafePerformIO $ newIORef 0 var2 = unsafePerformIO $ newIORef 0
GHC's CSE optimisation will common these up - after all, it's the same expression, so it must yield the same result, right?
Do these have to be within the same module for the CSE optimization to kick in? -- http://wagerlabs.com/
participants (3)
-
Joel Reymont
-
Simon Marlow
-
Tomasz Zielonka