
Yes! That's the code I like. On Feb 10, 2007, at 17:46 , Felipe Almeida Lessa wrote:
On 2/10/07, Rafael Almeida
wrote: While the haskell program took so long, the C program went really faster than the haskell version: $ gcc -O3 -ffast-math -mfpmath=sse -msse2 -std=c99 loop.c -o c_loop $ time ./c_loop 3.333333
real 0m0.001s user 0m0.000s sys 0m0.000s $ gcc --version gcc (GCC) 4.1.2 20061115 (prerelease) (Debian 4.1.1-21)
Under gcc (GCC) 4.1.2 20060928 (prerelease) (Ubuntu 4.1.1-13ubuntu5), the following asm code is generated for part of the main function:
mov dword ptr [esp+4], 0aaaaaaabh mov dword ptr [esp+8], 400aaaaah mov dword ptr [esp], data_804858c call wrapper_8049688_80482b4
where data_804858c is "%f\n" and wrapper_8049688_80482b4 is printf. Needless to say that the other argument is exactly the double 3.3333333333333335. In the OP's words, "newer gcc's will statically compute that loop".
-- Felipe. _______________________________________________ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe