#3138: Returning a known constructor: GHC generates terrible code for cmonad
-----------------------------------------+----------------------------------
    Reporter:  simonpj                   |        Owner:                  
        Type:  run-time performance bug  |       Status:  new             
    Priority:  normal                    |    Milestone:  6.12 branch     
   Component:  Compiler                  |      Version:  6.10.1          
    Severity:  normal                    |   Resolution:                  
    Keywords:                            |   Difficulty:  Unknown         
    Testcase:                            |           Os:  Unknown/Multiple
Architecture:  Unknown/Multiple          |  
-----------------------------------------+----------------------------------
Comment (by augustss):

 I expect the code to be the same as the code for
 {{{
 main = do
     rs <- newIORef 0
     ri <- newIORef 0
     writeIORef ri 1

     let loop = do
             i <- readIORef ri
             if i < 1e3 then do
                 s <- readIORef s
                 writeIORef rs (s + 1/i)
                 writeIORef ri (i+1)
                 loop
              else
                 return ()
     loop

     s <- readIORef rs
     putStrLn $ "Almost infinity is " ++ show s
 }}}
 Because that's what the code does.  Getting that far would require
 specializing the recursive while function (why doesn't ghc specialize
 recursive functions?).

-- 
Ticket URL: <http://hackage.haskell.org/trac/ghc/ticket/3138#comment:3>
GHC <http://www.haskell.org/ghc/>
The Glasgow Haskell Compiler
_______________________________________________
Glasgow-haskell-bugs mailing list
Glasgow-haskell-bugs@haskell.org
http://www.haskell.org/mailman/listinfo/glasgow-haskell-bugs

Reply via email to