id	summary	reporter	owner	description	type	status	priority	milestone	version	resolution	keywords	cc
20	Optimization strategy unclear (-Odph / -O2)	choener		"The vector tutorial states that -Odph should be used. On ghc 6.12.1 this leads to abysmal performance with some functions. Simple program attached. n=20000 has 60s (dph) vs. 5s (O2).

""g n"" is for comparison only and requires 12s (O2) if you are interested. -fno-method-sharing is required for good vector performance (otherwise: 17s).

{{{
{-# OPTIONS_GHC -fno-method-sharing #-}
module Main where

import qualified Data.Vector.Unboxed as V
import System.Environment (getArgs)

f :: Int -> Int
f n = V.sum $ V.concatMap (\k -> V.enumFromN 1 k) $ V.enumFromN 1 n

g :: Int -> Int
g n = sum $ concatMap (\k -> enumFromTo 1 k) $ enumFromTo 1 n

main = do
  (a:_) <- getArgs
  let n = read a :: Int
  print $ f n
}}}
"	defect	closed	major	0.7	0.6	wontfix	documentation, optimization	alexey.skladnoy@…
