diff options
Diffstat (limited to 'testsuite/tests/perf/should_run/T4830.hs')
-rw-r--r-- | testsuite/tests/perf/should_run/T4830.hs | 15 |
1 files changed, 15 insertions, 0 deletions
diff --git a/testsuite/tests/perf/should_run/T4830.hs b/testsuite/tests/perf/should_run/T4830.hs new file mode 100644 index 0000000000..e345ffc9cd --- /dev/null +++ b/testsuite/tests/perf/should_run/T4830.hs @@ -0,0 +1,15 @@ +-- Compile with O2; SpecConstr should fire nicely +-- and eliminate all allocation in inner loop + +module Main where + +foo :: Int -> Maybe (Double,Double) -> Double +foo _ Nothing = 0 +foo 0 (Just (x,y)) = x+y +foo n (Just (x,y)) = let r = f x y in r `seq` foo (n-1) (Just r) + where + f x y | x <= y = (x,y) + | otherwise = (y,x) + +main = print (foo 1000000 (Just (1,2))) + |