summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSimon Jakobi <simon.jakobi@gmail.com>2021-03-31 14:34:58 +0200
committerSimon Jakobi <simon.jakobi@gmail.com>2021-03-31 14:47:18 +0200
commitd35183fe88dc12c0a4727326afcee74819cdf1d3 (patch)
tree61e2af0279ee02c686cefd1d698bdffcfb6195ff
parent86e7aa01280543ec2b491fa112a86f7dbcf2a347 (diff)
downloadhaskell-wip/sjakobi/T14565-test.tar.gz
Add compiler perf test for #14565wip/sjakobi/T14565-test
Closes #14565.
-rw-r--r--testsuite/tests/perf/compiler/T14565.hs33
-rw-r--r--testsuite/tests/perf/compiler/all.T8
2 files changed, 41 insertions, 0 deletions
diff --git a/testsuite/tests/perf/compiler/T14565.hs b/testsuite/tests/perf/compiler/T14565.hs
new file mode 100644
index 0000000000..d7998e082e
--- /dev/null
+++ b/testsuite/tests/perf/compiler/T14565.hs
@@ -0,0 +1,33 @@
+-- GHC-8.2.2 gets stuck in SpecConstr while compiling this module
+module T14565 where
+
+import Control.Monad (forM_, when)
+import qualified Data.Vector.Unboxed as V
+import qualified Data.Vector.Unboxed.Mutable as VM
+
+data Dimensions = Dimensions Int Int Int Int
+ deriving (Show)
+
+-- Changing this to `toIdx = const 0` removes the issue.
+toIdx :: Dimensions -> Int
+toIdx (Dimensions _ _ _ _) = 0
+
+data Grid = Grid Dimensions (V.Vector Double)
+ deriving (Show)
+
+pointsGrid
+ :: Dimensions
+ -> Grid
+ -> Grid
+pointsGrid scs (Grid _ gv) = Grid scs $ V.create $ do
+ let v0 = V.fromList [(0::Int)]
+
+ v <- VM.replicate 100 0
+
+ -- Removing one of `V.forM_ v0` branches seems to remove the issue.
+ V.forM_ v0 $ \_ ->
+ V.forM_ v0 $ \_ ->
+ V.forM_ v0 $ \_ ->
+ V.forM_ v0 $ \_ -> VM.unsafeModify v (+ 0) (toIdx scs)
+
+ pure v
diff --git a/testsuite/tests/perf/compiler/all.T b/testsuite/tests/perf/compiler/all.T
index 937858c2a7..eee481dee5 100644
--- a/testsuite/tests/perf/compiler/all.T
+++ b/testsuite/tests/perf/compiler/all.T
@@ -452,3 +452,11 @@ test ('T9198',
[ collect_compiler_stats('bytes allocated',2) ],
compile,
[''])
+
+test('T14565',
+ [ reqlib('vector'),
+ only_ways(['optasm']),
+ collect_compiler_stats('bytes allocated',2),
+ ],
+ compile,
+ ['-O2 -fspec-constr'])