title: GHC 7.10 generates slower code than older versions
body: <p>I realized that the latest version of GHC (7.10.3) produces significantly slower code than an older version. My current version as of now:</p>
  
  <pre><code>$ ghc --version
  The Glorious Glasgow Haskell Compilation System, version 7.10.3
  </code></pre>
  
  <p>I have also two other old versions installed on my local machine.</p>
  
  <p>My test code is taken from <a href="http://www.mit.edu/~mtikekar/posts/stream-fusion.html" rel="nofollow">here</a> (the <code>collatz1.hs</code> code):</p>
  
  <pre><code>import Data.Word
  import Data.List
  import System.Environment
  
  collatzNext :: Word32 -&gt; Word32
  collatzNext a = (if even a then a else 3*a+1) `div` 2
  
  -- new code
  collatzLen :: Word32 -&gt; Int
  collatzLen a0 = lenIterWhile collatzNext (/= 1) a0
  
  lenIterWhile :: (a -&gt; a) -&gt; (a -&gt; Bool) -&gt; a -&gt; Int
  lenIterWhile next notDone start = len start 0 where
      len n m = if notDone n
                  then len (next n) (m+1)
                  else m
  -- End of new code
  
  main = do
      [a0] &lt;- getArgs
      let max_a0 = (read a0)::Word32
      print $ maximum $ map (\a0 -&gt; (collatzLen a0, a0)) [1..max_a0]
  </code></pre>
  
  <p>Compiling with GHC 7.4, 7.6 and 7.10 yields the following times:</p>
  
  <pre><code>$ ~/Tools/ghc-7.4.2/bin/ghc -O2 Test.hs 
  [1 of 1] Compiling Main             ( Test.hs, Test.o )
  Linking Test ...
  
  $ time ./Test 1000000
  (329,837799)
  
  real    0m1.879s
  user    0m1.876s
  sys     0m0.000s
  </code></pre>
  
  
  
  <pre><code>$ ~/Tools/ghc-7.6.1/bin/ghc -O2 Test.hs 
  [1 of 1] Compiling Main             ( Test.hs, Test.o )
  Linking Test ...
  
  $ time ./Test 1000000
  (329,837799)
  
  real    0m1.901s
  user    0m1.896s
  sys     0m0.000s
  </code></pre>
  
  
  
  <pre><code>$ ~/Tools/ghc/bin/ghc -O2 Test.hs 
  [1 of 1] Compiling Main             ( Test.hs, Test.o )
  Linking Test ...
  
  $ time ./Test 1000000
  (329,837799)
  
  real    0m10.562s
  user    0m10.528s
  sys     0m0.036s    
  </code></pre>
  
  <p>We can tell there is no doubt that the latest version of GHC produces worse code than the older two versions. I can't reproduce the same efficiency as the blog though probably because I don't have LLVM and Idon't have the exact version the author used. But still, I believe the conclusion is obvious.</p>
  
  <p>My question is, in general, why this could happen? Somehow GHC becomes worse than it used to be. And specifically, if I want to investigate, how should I get myself started?</p>