lookupBindGroupOcc: recommend names in the same namespace (#17593)
[ghc.git] / testsuite / tests / perf / should_run / T8763.hs
1 -- | The fusion helper for @enumFromThenTo \@Int@ had multiple
2 -- occurrences of @c@, which made the simplifier refuse to inline it.
3 -- The new implementation for @efdtInt{Up,Dn}FB@ only have a single
4 -- occurrence of @c@ which the simplifier inlines unconditionally.
5 module Main (main) where
6
7 import Control.Monad (when, forM_)
8 import GHC.ST
9
10 nop :: Monad m => a -> m ()
11 nop _ = return ()
12 {-# NOINLINE nop #-}
13
14 -- This is the baseline, using @enumFromTo@ which already had only a
15 -- single occurrence of @c@.
16 f :: Int -> ST s ()
17 f n =
18 do
19 forM_ [2..n] $ \p -> do
20 let isPrime = p == (p - 1)
21 when isPrime $
22 forM_ [p + p, p + p + p .. n] $ \k -> do
23 nop k
24 {-# NOINLINE f #-}
25
26 g :: Int -> ST s ()
27 g n =
28 do
29 forM_ [2,3..n] $ \p -> do
30 -- This do block should be too big to get inlined multiple times.
31 -- Pad with @nop@s as necessary if this doesn't reproduce anymore.
32 let isPrime = p == (p - 1)
33 when isPrime $
34 forM_ [p + p, p + p + p .. n] $ \k -> do
35 nop k
36 {-# NOINLINE g #-}
37
38 main :: IO ()
39 main = do
40 -- runST (f 40000000) `seq` return ()
41 runST (g 40000000) `seq` return ()