Skip to content

optLevelFlags is not monotonic

GHC 6.7.20070213 and all later versions I have fail to unbox this:

stefan@stefans:~/memset$ cat Memtest.hs
import Foreign

wset :: Int -> Int -> Ptr Int -> IO ()
wset x y z | x `seq` y `seq` z `seq` False = undefined
wset  0 vl pt = return ()
wset ct vl pt = poke pt vl >> wset (ct - 1) vl (pt `advancePtr` 1)

main = mallocArray (2^26) >>= wset (2^26) 42

with a resultant 15x performance regression:

stefan@stefans:~/memset$ ghc-6.7.20070213 -O3 Memtest.hs ; time ./a.out

real    0m5.774s
user    0m4.904s
sys     0m0.768s
stefan@stefans:~/memset$ ghc-6.6 -O3 Memtest.hs ; time ./a.out

real    0m1.043s
user    0m0.304s
sys     0m0.724s

(Toggling -fasm/-fvia-C makes no appreciable difference.)

Edited by Ian Lynagh -
To upload designs, you'll need to enable LFS and have an admin enable hashed storage. More information