summaryrefslogtreecommitdiff
path: root/testsuite
diff options
context:
space:
mode:
authorKevin Buhr <buhr@asaurus.net>2018-08-21 16:04:59 -0400
committerBen Gamari <ben@smart-cactus.org>2018-08-21 18:56:11 -0400
commit14817621aae2d45f8272a36b171b9ccce8763bba (patch)
treedfbd14247689d57a666d85cf50c7e7e5c4599701 /testsuite
parent2bacf6f8842d8e1288917e358ed41e4c61b7948e (diff)
downloadhaskell-14817621aae2d45f8272a36b171b9ccce8763bba.tar.gz
base: Mark `findIndices` as INLINABLE instead of INLINE (fixes #15426)
If `findIndices` is marked INLINE in `Data.OldList`, then the unfolded versions of `elemIndex` and `findIndex` included in the interface file are unfusible (even though `findIndices` itself remains fusible). By marking it INLINABLE instead, elemIndex` and `findIndex` will fuse properly. Test Plan: make TEST=T15426 Reviewers: hvr, bgamari Reviewed By: bgamari Subscribers: rwbarton, carter GHC Trac Issues: #15426 Differential Revision: https://phabricator.haskell.org/D5063
Diffstat (limited to 'testsuite')
-rw-r--r--testsuite/tests/perf/should_run/T15426.hs13
-rw-r--r--testsuite/tests/perf/should_run/all.T9
2 files changed, 22 insertions, 0 deletions
diff --git a/testsuite/tests/perf/should_run/T15426.hs b/testsuite/tests/perf/should_run/T15426.hs
new file mode 100644
index 0000000000..de88c28ce0
--- /dev/null
+++ b/testsuite/tests/perf/should_run/T15426.hs
@@ -0,0 +1,13 @@
+import Control.Exception (evaluate)
+import Data.List
+
+-- The following will fuse with minimal heap usage provided
+-- `findIndices` is marked `INLINABLE` instead of `INLINE`.
+
+unsafeFindIndex p = head . findIndices p
+
+main = do evaluate $ elemIndex 999999 [(1::Int)..1000000]
+ evaluate $ elemIndices 999999 [(1::Int)..1000000]
+ evaluate $ findIndex (>=999999) [(1::Int)..1000000]
+ evaluate $ findIndices (>=999999) [(1::Int)..1000000]
+ evaluate $ unsafeFindIndex (>=999999) [(1::Int)..1000000]
diff --git a/testsuite/tests/perf/should_run/all.T b/testsuite/tests/perf/should_run/all.T
index 9705a08f80..6a7bcf0040 100644
--- a/testsuite/tests/perf/should_run/all.T
+++ b/testsuite/tests/perf/should_run/all.T
@@ -595,3 +595,12 @@ test('T15226a',
only_ways(['normal'])],
compile_and_run,
['-O'])
+
+test('T15426',
+ [stats_num_field('bytes allocated',
+ [ (wordsize(64), 41272, 20) ]),
+ # 2018-08-10 41272 Change findIndices from INLINE to INLINABLE
+ # initial 160041176
+ only_ways(['normal'])],
+ compile_and_run,
+ ['-O2'])