summaryrefslogtreecommitdiff
path: root/testsuite
diff options
context:
space:
mode:
authorSimon Jakobi <simon.jakobi@gmail.com>2021-03-29 17:30:17 +0200
committerMarge Bot <ben+marge-bot@smart-cactus.org>2021-03-30 17:40:14 -0400
commit128fd85cd266550b0cf19454cd218a85585ee18e (patch)
treefd210b3bc0b6b9d391a5a8f3e00a8f8caab12f64 /testsuite
parent470839c5feb65cf745b5fe624aece5884c8e53d2 (diff)
downloadhaskell-128fd85cd266550b0cf19454cd218a85585ee18e.tar.gz
Add regression test for #5298
Closes #5298.
Diffstat (limited to 'testsuite')
-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