Fold integer-simple.git into ghc.git (re #8545)
[ghc.git] / testsuite / tests / perf / should_run / T3586.hs
1 {-# LANGUAGE BangPatterns #-}
2 {-# OPTIONS -fvia-C -optc-O3 -fexcess-precision -optc-msse3 #-}
3
4 import Control.Monad.ST
5 import Data.Array.ST
6 import Data.Array.Base
7
8 main = print $ runST
9 (do arr <- newArray (1,2000000) 137.0 :: ST s (STUArray s Int Double)
10 go arr 2000000 0.0 )
11
12
13 go :: STUArray s Int Double -> Int -> Double -> ST s Double
14 go !a i !acc
15 | i < 1 = return acc
16 | otherwise = do
17 b <- unsafeRead a i
18 unsafeWrite a i (b+3.0)
19 c <- unsafeRead a i
20 go a (i-1) (c+acc)