diff options
Diffstat (limited to 'testsuite/tests/perf/should_run/3586.hs')
-rw-r--r-- | testsuite/tests/perf/should_run/3586.hs | 20 |
1 files changed, 20 insertions, 0 deletions
diff --git a/testsuite/tests/perf/should_run/3586.hs b/testsuite/tests/perf/should_run/3586.hs new file mode 100644 index 0000000000..968f2eba27 --- /dev/null +++ b/testsuite/tests/perf/should_run/3586.hs @@ -0,0 +1,20 @@ +{-# LANGUAGE BangPatterns #-} +{-# OPTIONS -fvia-C -optc-O3 -fexcess-precision -optc-msse3 #-} + +import Control.Monad.ST +import Data.Array.ST +import Data.Array.Base + +main = print $ runST + (do arr <- newArray (1,2000000) 137.0 :: ST s (STUArray s Int Double) + go arr 2000000 0.0 ) + + +go :: STUArray s Int Double -> Int -> Double -> ST s Double +go !a i !acc + | i < 1 = return acc + | otherwise = do + b <- unsafeRead a i + unsafeWrite a i (b+3.0) + c <- unsafeRead a i + go a (i-1) (c+acc) |