Silly IO problem

2005-11-02 Thread skaller
This code doesn't work: import System(getArgs) main = do n <- getArgs >>= readIO.head putStrLn (show (tak (3*n) (2*n) n)) tak :: Float -> Float -> Float -> Float tak x y z | y>=x = z | otherwise = tak (tak (x-1) y z) (tak (y-1) z x) (tak (z-1) x y

Re: jhc vs ghc and the surprising result involving ghc generated assembly.

2005-11-02 Thread skaller
On Wed, 2005-11-02 at 19:47 +0100, Florian Weimer wrote: > >> It seems that the goto-based version leads to different static branch > >> prediction results, which happen to be favorable. > > > > It has nothing to do with branch prediction. I know > > it is determined ENTIRELY by stack use. > > I

Re: jhc vs ghc and the surprising result involving ghc generatedassembly.

2005-11-02 Thread skaller
On Wed, 2005-11-02 at 18:05 +0100, Florian Weimer wrote: > >> Is it correct that you use indirect gotos across functions? Such > >> gotos aren't supported by GCC and work only by accident. > > > > Even direct gotos aren't universally supported. Some info > > in Fergus Henderson's paper may be of i

Re: jhc vs ghc and the surprising result involving ghcgeneratedassembly.

2005-11-02 Thread Florian Weimer
* Lennart Augustsson: > Simon Marlow wrote: >>>Is it correct that you use indirect gotos across functions? Such >>>gotos aren't supported by GCC and work only by accident. >> Yes, but cross-function gotos are always to the beginning of a >> function. > > Is that enough to ensure that the constant

Re: jhc vs ghc and the surprising result involving ghc generated assembly.

2005-11-02 Thread Florian Weimer
>> It seems that the goto-based version leads to different static branch >> prediction results, which happen to be favorable. > > It has nothing to do with branch prediction. I know > it is determined ENTIRELY by stack use. In both cases, The C compiler emits code which doesn't use the stack. __

Re: jhc vs ghc and the surprising result involving ghcgeneratedassembly.

2005-11-02 Thread Lennart Augustsson
Simon Marlow wrote: Is it correct that you use indirect gotos across functions? Such gotos aren't supported by GCC and work only by accident. Yes, but cross-function gotos are always to the beginning of a function. Is that enough to ensure that the constant pool base register is reloaded on

Re: jhc vs ghc and the surprising result involving ghc generatedassembly.

2005-11-02 Thread Florian Weimer
>> Is it correct that you use indirect gotos across functions? Such >> gotos aren't supported by GCC and work only by accident. > > Even direct gotos aren't universally supported. Some info > in Fergus Henderson's paper may be of interest > > http://felix.sourceforge.net/papers/mercury_to_c.ps Th

Re: jhc vs ghc and the surprising result involving ghc generatedassembly.

2005-11-02 Thread skaller
On Wed, 2005-11-02 at 14:59 +0100, Florian Weimer wrote: > Is it correct that you use indirect gotos across functions? Such > gotos aren't supported by GCC and work only by accident. Even direct gotos aren't universally supported. Some info in Fergus Henderson's paper may be of interest http:/

Re: jhc vs ghc and the surprising result involving ghcgeneratedassembly.

2005-11-02 Thread Florian Weimer
* Simon Marlow: >> However, beginning with GCC 3.4, you can use: >> >> extern void bar(); >> >> void foo() >> { >> void (*p)(void) = bar; >> p(); >> } > > Interesting.. though I'm not sure I'm comfortable with relying on gcc's > tail call optimisation to do the right thing. Aren't there sid

RE: jhc vs ghc and the surprising result involving ghcgeneratedassembly.

2005-11-02 Thread Simon Marlow
On 02 November 2005 13:59, Florian Weimer wrote: > However, beginning with GCC 3.4, you can use: > > extern void bar(); > > void foo() > { > void (*p)(void) = bar; > p(); > } Interesting.. though I'm not sure I'm comfortable with relying on gcc's tail call optimisation to do the right thing

Re: jhc vs ghc and the surprising result involving ghc generatedassembly.

2005-11-02 Thread Florian Weimer
* Simon Marlow: >>> gcc started generating this rubbish around version 3.4, if I recall >>> correctly. I've tried disabling various optimisations, but can't >>> seem to convince gcc not to generate the extra jump. You don't get >>> this from the native code generator, BTW. >> >> But the compari

RE: Array operations and pinning

2005-11-02 Thread Simon Marlow
On 02 November 2005 11:15, Rene de Visser wrote: > Where is the documentation on how pinning works in the GHC garbage > collector (from a GHC users point of view). > > I have copied the following code from array/IO.hs and am thinking > that it is assuming that the array is pinned? What triggers t

Re: jhc vs ghc and the surprising result involving ghc generated assembly.

2005-11-02 Thread Tony Finch
On Wed, 2 Nov 2005, skaller wrote: > On Tue, 2005-11-01 at 19:03 +0100, Florian Weimer wrote: > > > BTW, you shouldn't generate identifiers with leading underscores > > because they are reserved for the implementation. > > I AM the implementation :) You are not the C implementation. > Generated I

Array operations and pinning

2005-11-02 Thread Rene de Visser
Hello, Where is the documentation on how pinning works in the GHC garbage collector (from a GHC users point of view). I have copied the following code from array/IO.hs and am thinking that it is assuming that the array is pinned? What triggers the pinning? On a second note. Why is the type

RE: jhc vs ghc and the surprising result involving ghc generatedassembly.

2005-11-02 Thread Simon Marlow
On 01 November 2005 16:32, Florian Weimer wrote: > * Simon Marlow: > >> gcc started generating this rubbish around version 3.4, if I recall >> correctly. I've tried disabling various optimisations, but can't >> seem to convince gcc not to generate the extra jump. You don't get >> this from the