summaryrefslogtreecommitdiff
path: root/testsuite
diff options
context:
space:
mode:
authorM Farkas-Dyck <strake888@proton.me>2022-09-18 20:23:23 -0800
committerMarge Bot <ben+marge-bot@smart-cactus.org>2022-11-08 12:53:55 -0500
commit68f49874aa217c2222c80c596ef11ffd992b459a (patch)
tree215cafabd967e33b9d1c70182474d3690d1767fa /testsuite
parent5fe11fe612e1881bd4d1b9d5950d0d801e08e159 (diff)
downloadhaskell-68f49874aa217c2222c80c596ef11ffd992b459a.tar.gz
Define `Infinite` list and use where appropriate.
Also add perf test for infinite list fusion. In particular, in `GHC.Core`, often we deal with infinite lists of roles. Also in a few locations we deal with infinite lists of names. Thanks to simonpj for helping to write the Note [Fusion for `Infinite` lists].
Diffstat (limited to 'testsuite')
-rw-r--r--testsuite/tests/count-deps/CountDepsAst.stdout1
-rw-r--r--testsuite/tests/count-deps/CountDepsParser.stdout1
-rw-r--r--testsuite/tests/perf/compiler/InfiniteListFusion.hs9
-rw-r--r--testsuite/tests/perf/compiler/InfiniteListFusion.stdout1
-rw-r--r--testsuite/tests/perf/compiler/all.T7
5 files changed, 18 insertions, 1 deletions
diff --git a/testsuite/tests/count-deps/CountDepsAst.stdout b/testsuite/tests/count-deps/CountDepsAst.stdout
index b875e35ddb..212a79d42a 100644
--- a/testsuite/tests/count-deps/CountDepsAst.stdout
+++ b/testsuite/tests/count-deps/CountDepsAst.stdout
@@ -87,6 +87,7 @@ GHC.Data.FiniteMap
GHC.Data.Graph.Directed
GHC.Data.Graph.UnVar
GHC.Data.IOEnv
+GHC.Data.List.Infinite
GHC.Data.List.SetOps
GHC.Data.Maybe
GHC.Data.OrdList
diff --git a/testsuite/tests/count-deps/CountDepsParser.stdout b/testsuite/tests/count-deps/CountDepsParser.stdout
index 2926e7b6bf..807e8f02ed 100644
--- a/testsuite/tests/count-deps/CountDepsParser.stdout
+++ b/testsuite/tests/count-deps/CountDepsParser.stdout
@@ -87,6 +87,7 @@ GHC.Data.FiniteMap
GHC.Data.Graph.Directed
GHC.Data.Graph.UnVar
GHC.Data.IOEnv
+GHC.Data.List.Infinite
GHC.Data.List.SetOps
GHC.Data.Maybe
GHC.Data.OrdList
diff --git a/testsuite/tests/perf/compiler/InfiniteListFusion.hs b/testsuite/tests/perf/compiler/InfiniteListFusion.hs
new file mode 100644
index 0000000000..5bfd9d7122
--- /dev/null
+++ b/testsuite/tests/perf/compiler/InfiniteListFusion.hs
@@ -0,0 +1,9 @@
+module Main where
+
+import qualified GHC.Data.List.Infinite as Inf
+
+main :: IO ()
+main = print $ sum $ take (2^16) $ Inf.toList $ Inf.filter isEven $ Inf.iterate succ (0 :: Int)
+
+isEven :: Integral a => a -> Bool
+isEven n = 0 == mod n 2
diff --git a/testsuite/tests/perf/compiler/InfiniteListFusion.stdout b/testsuite/tests/perf/compiler/InfiniteListFusion.stdout
new file mode 100644
index 0000000000..c584a2a13b
--- /dev/null
+++ b/testsuite/tests/perf/compiler/InfiniteListFusion.stdout
@@ -0,0 +1 @@
+4294901760
diff --git a/testsuite/tests/perf/compiler/all.T b/testsuite/tests/perf/compiler/all.T
index a70b93df01..e6e46ba62e 100644
--- a/testsuite/tests/perf/compiler/all.T
+++ b/testsuite/tests/perf/compiler/all.T
@@ -649,4 +649,9 @@ test('T21839c',
[ collect_compiler_stats('all', 1),
only_ways(['normal'])],
compile,
- ['-O']) \ No newline at end of file
+ ['-O'])
+
+test ('InfiniteListFusion',
+ [collect_stats('bytes allocated',2), when(arch('i386'), skip)],
+ compile_and_run,
+ ['-O2 -package ghc'])