summaryrefslogtreecommitdiff
path: root/testsuite
diff options
context:
space:
mode:
authorSimon Peyton Jones <simon.peytonjones@gmail.com>2023-01-26 15:35:41 +0000
committerMarge Bot <ben+marge-bot@smart-cactus.org>2023-01-30 21:20:35 -0500
commitd0f34f25ceaae9ef0a21f15f811469d0bed9da69 (patch)
treec42d57f585cef54e0a9e2a52956d45eadb949ade /testsuite
parent2f1450521b816a7d287b72deba14d59b6ccfbdbf (diff)
downloadhaskell-d0f34f25ceaae9ef0a21f15f811469d0bed9da69.tar.gz
Take account of loop breakers in specLookupRule
The key change is that in GHC.Core.Opt.Specialise.specLookupRule we were using realIdUnfolding, which ignores the loop-breaker flag. When given a loop breaker, rule matching therefore looped infinitely -- #22802. In fixing this I refactored a bit. * Define GHC.Core.InScopeEnv as a data type, and use it. (Previously it was a pair: hard to grep for.) * Put several functions returning an IdUnfoldingFun into GHC.Types.Id, namely idUnfolding alwaysActiveUnfoldingFun, whenActiveUnfoldingFun, noUnfoldingFun and use them. (The are all loop-breaker aware.)
Diffstat (limited to 'testsuite')
-rw-r--r--testsuite/tests/simplCore/should_compile/T22802.hs20
-rw-r--r--testsuite/tests/simplCore/should_compile/all.T1
2 files changed, 21 insertions, 0 deletions
diff --git a/testsuite/tests/simplCore/should_compile/T22802.hs b/testsuite/tests/simplCore/should_compile/T22802.hs
new file mode 100644
index 0000000000..2df903598d
--- /dev/null
+++ b/testsuite/tests/simplCore/should_compile/T22802.hs
@@ -0,0 +1,20 @@
+{-# OPTIONS_GHC -O1 #-}
+module T22802 where
+
+class C a where
+ f :: a -> a -> a
+ g :: a -> a -> a
+instance C () where
+ f = g
+ g = f
+
+h :: a -> () -> ()
+h = mapFB f (const ())
+
+mapFB :: (elt -> lst -> lst) -> (a -> elt) -> a -> lst -> lst
+{-# INLINE [0] mapFB #-}
+mapFB c f = \x ys -> c (f x) ys
+
+{-# RULES
+"my-mapFB" forall c a b. mapFB (mapFB c a) b = mapFB c (a.b)
+ #-}
diff --git a/testsuite/tests/simplCore/should_compile/all.T b/testsuite/tests/simplCore/should_compile/all.T
index a07aba3940..745bb22cd9 100644
--- a/testsuite/tests/simplCore/should_compile/all.T
+++ b/testsuite/tests/simplCore/should_compile/all.T
@@ -470,3 +470,4 @@ test('T22725', normal, compile, ['-O'])
test('T22502', normal, compile, ['-O'])
test('T22611', [when(wordsize(32), skip), grep_errmsg(r'\$salterF') ], compile, ['-O -ddump-simpl -dsuppress-uniques -dsuppress-all'])
test('T22715_2', normal, multimod_compile, ['T22715_2', '-v0 -O -fspecialise-aggressively'])
+test('T22802', normal, compile, ['-O'])