summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSimon Jakobi <simon.jakobi@gmail.com>2021-03-29 17:30:17 +0200
committerSimon Jakobi <simon.jakobi@gmail.com>2021-03-29 18:43:25 +0200
commita5c16f185b97e8d170ca83a4e7744d8b09c5bf3b (patch)
tree402030c67c2f5e3fe14cf712493ae24ea95c9d07
parent9c9e40e59214b1e358c85852218f3a67e712a748 (diff)
downloadhaskell-wip/sjakobi/T5298.tar.gz
Add regression test for #5298wip/sjakobi/T5298
Closes #5298.
-rw-r--r--testsuite/tests/simplCore/should_compile/Makefile6
-rw-r--r--testsuite/tests/simplCore/should_compile/T5298.stdout15
-rw-r--r--testsuite/tests/simplCore/should_compile/T5298A.hs10
-rw-r--r--testsuite/tests/simplCore/should_compile/T5298B.hs6
-rw-r--r--testsuite/tests/simplCore/should_compile/all.T1
5 files changed, 38 insertions, 0 deletions
diff --git a/testsuite/tests/simplCore/should_compile/Makefile b/testsuite/tests/simplCore/should_compile/Makefile
index 3712fd5477..08d1798fa8 100644
--- a/testsuite/tests/simplCore/should_compile/Makefile
+++ b/testsuite/tests/simplCore/should_compile/Makefile
@@ -156,6 +156,12 @@ simpl021:
'$(TEST_HC)' $(TEST_HC_OPTS) -c Simpl021A.hs -O
'$(TEST_HC)' $(TEST_HC_OPTS) -c Simpl021B.hs -O
+.PHONY: T5298
+T5298:
+ $(RM) -f T5298A.hi T5298A.o T5298B.hi T5298B.o
+ '$(TEST_HC)' $(TEST_HC_OPTS) T5298B.hs -O -ddump-simpl -dsuppress-all -dsuppress-uniques | grep -E -A6 '^(.w)?g'
+ # The g function should be fully specialized
+
.PHONY: T5327
T5327:
$(RM) -f T5327.hi T5327.o
diff --git a/testsuite/tests/simplCore/should_compile/T5298.stdout b/testsuite/tests/simplCore/should_compile/T5298.stdout
new file mode 100644
index 0000000000..370f9776e2
--- /dev/null
+++ b/testsuite/tests/simplCore/should_compile/T5298.stdout
@@ -0,0 +1,15 @@
+$wg
+ = \ ww ->
+ case ww of wild {
+ __DEFAULT ->
+ case $wg (-# wild 1#) of ww1 { __DEFAULT -> *# wild ww1 };
+ 0# -> 1#
+ }
+--
+g = \ w ->
+ case w of { I# ww1 -> case $wg ww1 of ww2 { __DEFAULT -> I# ww2 } }
+
+
+------ Local rules for imported ids --------
+"SPEC/T5298B fac @Int" forall $dEq $dNum. fac $dEq $dNum = g
+
diff --git a/testsuite/tests/simplCore/should_compile/T5298A.hs b/testsuite/tests/simplCore/should_compile/T5298A.hs
new file mode 100644
index 0000000000..f58642910e
--- /dev/null
+++ b/testsuite/tests/simplCore/should_compile/T5298A.hs
@@ -0,0 +1,10 @@
+module T5298A where
+
+{-# INLINABLE fac #-}
+fac :: (Eq a, Num a) => a -> a
+fac 0 = 1
+fac n = n * fac (n-1)
+
+{-# INLINE f #-}
+f :: (Eq a, Num a) => a -> a
+f a = fac a
diff --git a/testsuite/tests/simplCore/should_compile/T5298B.hs b/testsuite/tests/simplCore/should_compile/T5298B.hs
new file mode 100644
index 0000000000..748c42c317
--- /dev/null
+++ b/testsuite/tests/simplCore/should_compile/T5298B.hs
@@ -0,0 +1,6 @@
+module T5298B where
+
+import T5298A
+
+g :: Int -> Int
+g x = f x
diff --git a/testsuite/tests/simplCore/should_compile/all.T b/testsuite/tests/simplCore/should_compile/all.T
index 23058c2cd8..3a16d55508 100644
--- a/testsuite/tests/simplCore/should_compile/all.T
+++ b/testsuite/tests/simplCore/should_compile/all.T
@@ -105,6 +105,7 @@ test('T5168',
normal,
makefile_test, ['T5168'])
+test('T5298', [extra_files(['T5298A.hs', 'T5298B.hs'])], makefile_test, ['T5298'])
test('T5329', normal, compile, [''])
test('T5303', normal, compile, ['']) # Coercion-optimisation test
test('T5342', normal, compile, ['']) # Lint error with -prof