#1957: Program that runs slower with optimizations on
----------------------+-----------------------------------------------------
Reporter: clanehin | Owner:
Type: bug | Status: new
Priority: normal | Milestone:
Component: Compiler | Version: 6.8.1
Severity: normal | Resolution:
Keywords: | Difficulty: Unknown
Testcase: | Architecture: x86
Os: Linux |
----------------------+-----------------------------------------------------
Comment (by clanehin):
Forgot to preview. Sorry.
{{{
[EMAIL PROTECTED]:~/test/optimizer-bug$ more Main.hs NaiveFib.hs
::::::::::::::
Main.hs
::::::::::::::
module Main
(main)
where
import NaiveFib
import Control.Monad
main :: IO ()
main = replicateM_ 10 (printFib 37)
::::::::::::::
NaiveFib.hs
::::::::::::::
module NaiveFib
(printFib,naiveFib)
where
printFib :: Integer -> IO ()
printFib = print . naiveFib
naiveFib :: Integer -> Integer
naiveFib 0 = 0
naiveFib 1 = 1
naiveFib n = naiveFib (n-1) + naiveFib (n-2)
[EMAIL PROTECTED]:~/test/optimizer-bug$ make main-O0
ghc-6.8.1 -O0 --make Main.hs -o main-O0
[1 of 2] Compiling NaiveFib ( NaiveFib.hs, NaiveFib.o )
[2 of 2] Compiling Main ( Main.hs, Main.o )
Linking main-O0 ...
[EMAIL PROTECTED]:~/test/optimizer-bug$ time ./main-O0
24157817
24157817
24157817
24157817
24157817
24157817
24157817
24157817
24157817
24157817
real 0m34.491s
user 0m25.982s
sys 0m0.564s
[EMAIL PROTECTED]:~/test/optimizer-bug$ make clean
rm -f *.hi
rm -f *.o
rm -f main-O2
rm -f main-O0
[EMAIL PROTECTED]:~/test/optimizer-bug$ make main-O2
ghc-6.8.1 -O2 --make Main.hs -o main-O2
[1 of 2] Compiling NaiveFib ( NaiveFib.hs, NaiveFib.o )
[2 of 2] Compiling Main ( Main.hs, Main.o )
Linking main-O2 ...
[EMAIL PROTECTED]:~/test/optimizer-bug$ time ./main-O2
24157817
24157817
24157817
24157817
24157817
24157817
24157817
24157817
24157817
24157817
real 1m50.331s
user 1m23.641s
sys 0m1.008s
}}}
--
Ticket URL: <http://hackage.haskell.org/trac/ghc/ticket/1957#comment:1>
GHC <http://www.haskell.org/ghc/>
The Glasgow Haskell Compiler_______________________________________________
Glasgow-haskell-bugs mailing list
[email protected]
http://www.haskell.org/mailman/listinfo/glasgow-haskell-bugs