summaryrefslogtreecommitdiff
path: root/testsuite
diff options
context:
space:
mode:
Diffstat (limited to 'testsuite')
-rw-r--r--testsuite/tests/perf/compiler/T4007.stdout4
-rw-r--r--testsuite/tests/perf/should_run/T8763.hs41
-rw-r--r--testsuite/tests/perf/should_run/all.T7
3 files changed, 51 insertions, 1 deletions
diff --git a/testsuite/tests/perf/compiler/T4007.stdout b/testsuite/tests/perf/compiler/T4007.stdout
index 9b23359663..14e7bf82e3 100644
--- a/testsuite/tests/perf/compiler/T4007.stdout
+++ b/testsuite/tests/perf/compiler/T4007.stdout
@@ -1,8 +1,10 @@
Rule fired: Class op foldr (BUILTIN)
-Rule fired: Class op >> (BUILTIN)
Rule fired: Class op return (BUILTIN)
Rule fired: unpack (GHC.Base)
Rule fired: fold/build (GHC.Base)
+Rule fired: Class op >> (BUILTIN)
+Rule fired: Class op >> (BUILTIN)
+Rule fired: SPEC/T4007 sequence__c @ IO _ _ (T4007)
Rule fired: <# (BUILTIN)
Rule fired: tagToEnum# (BUILTIN)
Rule fired: unpack-list (GHC.Base)
diff --git a/testsuite/tests/perf/should_run/T8763.hs b/testsuite/tests/perf/should_run/T8763.hs
new file mode 100644
index 0000000000..90c4436ce9
--- /dev/null
+++ b/testsuite/tests/perf/should_run/T8763.hs
@@ -0,0 +1,41 @@
+-- | The fusion helper for @enumFromThenTo \@Int@ had multiple
+-- occurences of @c@, which made the simplifier refuse to inline it.
+-- The new implementation for @efdtInt{Up,Dn}FB@ only have a single
+-- occurence of @c@ which the simplifier inlines unconditionally.
+module Main (main) where
+
+import Control.Monad (when, forM_)
+import GHC.ST
+
+nop :: Monad m => a -> m ()
+nop _ = return ()
+{-# NOINLINE nop #-}
+
+-- This is the baseline, using @enumFromTo@ which already had only a
+-- single occurence of @c@.
+f :: Int -> ST s ()
+f n =
+ do
+ forM_ [2..n] $ \p -> do
+ let isPrime = p == (p - 1)
+ when isPrime $
+ forM_ [p + p, p + p + p .. n] $ \k -> do
+ nop k
+{-# NOINLINE f #-}
+
+g :: Int -> ST s ()
+g n =
+ do
+ forM_ [2,3..n] $ \p -> do
+ -- This do block should be too big to get inlined multiple times.
+ -- Pad with @nop@s as necessary if this doesn't reproduce anymore.
+ let isPrime = p == (p - 1)
+ when isPrime $
+ forM_ [p + p, p + p + p .. n] $ \k -> do
+ nop k
+{-# NOINLINE g #-}
+
+main :: IO ()
+main = do
+ -- runST (f 40000000) `seq` return ()
+ runST (g 40000000) `seq` return ()
diff --git a/testsuite/tests/perf/should_run/all.T b/testsuite/tests/perf/should_run/all.T
index 1a85e7073d..37ce0a454f 100644
--- a/testsuite/tests/perf/should_run/all.T
+++ b/testsuite/tests/perf/should_run/all.T
@@ -518,6 +518,13 @@ test('T13001',
compile_and_run,
['-O2'])
+test('T8763',
+ [stats_num_field('bytes allocated',
+ [ (wordsize(64), 41056, 20) ]),
+ only_ways(['normal'])],
+ compile_and_run,
+ ['-O2'])
+
test('T12990',
[stats_num_field('bytes allocated',
[ (wordsize(64), 20040936, 5) ]),