id,summary,reporter,owner,description,type,status,priority,milestone,component,version,resolution,keywords,cc,os,architecture,failure,difficulty,testcase,blockedby,blocking,related
4065,Inconsistent loop performance,rl,,"Here are two small benchmarks:

{{{
import Criterion.Main

foo :: Int -> Int -> Int
foo n k | n <= 0    = k
        | otherwise = foo (n-1) (k+1)

bar :: Int -> Int -> Int
bar n k | n == 0    = k
        | otherwise = bar (n-1) (k+1)

main :: IO ()
main = defaultMain [ bench ""foo"" $ nf (uncurry foo) (20000000,0)
                   , bench ""bar"" $ nf (uncurry bar) (20000000,0)
                   ]
}}}

On my laptop, I consistently get a mean running time of about 36ms for `foo` and about 45ms for `bar`. This is a rather big difference. The Core looks about the same and going via C gives me about 42ms for both loops so this is certainly a code generator problem.",bug,closed,normal,7.6.1,Compiler,6.13,fixed,,ezyang dterei,Unknown/Multiple,Unknown/Multiple,Runtime performance bug,Unknown,,,,
