Simon Jakobi pushed to branch wip/sjakobi/T4081 at Glasgow Haskell Compiler / GHC
Commits:
30413303 by Simon Jakobi at 2026-06-02T11:42:31+02:00
testsuite: Add regression test for #4081
Check that a strict constructor field is unboxed once outside an
enclosing loop, not re-inspected each iteration (the float-out
case-floating from 9cb20b488). Uses simonpj's `data T a = T !a` example
from the ticket; T4081.stderr captures the expected Core.
Co-Authored-By: Claude Opus 4.7
- - - - -
3 changed files:
- + testsuite/tests/simplCore/should_compile/T4081.hs
- + testsuite/tests/simplCore/should_compile/T4081.stderr
- testsuite/tests/simplCore/should_compile/all.T
Changes:
=====================================
testsuite/tests/simplCore/should_compile/T4081.hs
=====================================
@@ -0,0 +1,11 @@
+-- #4081: the strict field of T should be unboxed once, outside the blah loop,
+-- not re-inspected on every iteration. See the expected Core in T4081.stderr.
+
+module T4081 (foo) where
+
+data T a = T !a
+
+foo :: T Int -> Int -> Int
+foo (T x) y = let blah 0 = 0
+ blah n = x + blah (n-1)
+ in blah y
=====================================
testsuite/tests/simplCore/should_compile/T4081.stderr
=====================================
@@ -0,0 +1,29 @@
+
+==================== Tidy Core ====================
+Result size of Tidy Core
+ = {terms: 40, types: 25, coercions: 0, joins: 0/1}
+
+$wfoo
+ = \ ww ww1 ->
+ letrec {
+ $wblah
+ = \ ww2 ->
+ case ww2 of ds {
+ __DEFAULT ->
+ case $wblah (-# ds 1#) of ww3 { __DEFAULT -> +# ww ww3 };
+ 0# -> 0#
+ }; } in
+ $wblah ww1
+
+foo
+ = \ ds y ->
+ case ds of { T ww ->
+ case ww of { I# ww1 ->
+ case y of { I# ww2 ->
+ case $wfoo ww1 ww2 of ww3 { __DEFAULT -> I# ww3 }
+ }
+ }
+ }
+
+
+
=====================================
testsuite/tests/simplCore/should_compile/all.T
=====================================
@@ -601,4 +601,6 @@ test('T25718a', normal, compile, ['-O -ddump-simpl -dsuppress-uniques -dsuppress
test('T25718b', normal, compile, ['-O -ddump-simpl -dsuppress-uniques -dsuppress-all -dno-typeable-binds'])
test('T25718c', normal, compile, ['-O -ddump-simpl -dsuppress-uniques -dsuppress-all -dno-typeable-binds'])
test('T19166', normal, compile, ['-O -ddump-simpl -dsuppress-uniques -dsuppress-all -dno-typeable-binds'])
+# #4081: the strict field of T should be unboxed once, outside the loop.
+test('T4081', normal, compile, ['-O -ddump-simpl -dsuppress-uniques -dsuppress-all -dno-typeable-binds'])
test('T27261', [extra_files(['T27261_aux.hs'])], multimod_compile, ['T27261', '-v0 -O'])
View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/304133030893df192717cfbf5ba04003...
--
View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/304133030893df192717cfbf5ba04003...
You're receiving this email because of your account on gitlab.haskell.org.