summaryrefslogtreecommitdiff
path: root/compiler
diff options
context:
space:
mode:
authorSimon Peyton Jones <simonpj@microsoft.com>2018-10-24 17:15:15 +0100
committerSimon Peyton Jones <simonpj@microsoft.com>2018-10-25 09:10:00 +0100
commit232b0cb35c1f731be66a032a4deee87bc47db3c9 (patch)
tree5f87b239efd3fce8da00e3f22931e6f5f3e40d32 /compiler
parenta3476aa265a4448df9c8d3333d6829a898108af6 (diff)
downloadhaskell-232b0cb35c1f731be66a032a4deee87bc47db3c9.tar.gz
Add comments for StgCse and Unarise
This just improves docmentation for the fix to Trac #15300
Diffstat (limited to 'compiler')
-rw-r--r--compiler/simplStg/SimplStg.hs2
-rw-r--r--compiler/simplStg/StgCse.hs16
2 files changed, 18 insertions, 0 deletions
diff --git a/compiler/simplStg/SimplStg.hs b/compiler/simplStg/SimplStg.hs
index 36bf5101d6..830dd19aea 100644
--- a/compiler/simplStg/SimplStg.hs
+++ b/compiler/simplStg/SimplStg.hs
@@ -40,6 +40,8 @@ stg2stg dflags binds
; stg_linter False "Pre-unarise" binds
; let un_binds = unarise us binds
; stg_linter True "Unarise" un_binds
+ -- Important that unarisation comes first
+ -- See Note [StgCse after unarisation] in StgCse
; dumpIfSet_dyn dflags Opt_D_dump_stg "STG syntax:"
(pprStgTopBindings un_binds)
diff --git a/compiler/simplStg/StgCse.hs b/compiler/simplStg/StgCse.hs
index 1ae1213960..2caf006e3f 100644
--- a/compiler/simplStg/StgCse.hs
+++ b/compiler/simplStg/StgCse.hs
@@ -67,7 +67,23 @@ and nothing stops us from transforming that to
foo [e] = case e of b { Left [n] -> …
, Right [x] -> b}
+
+Note [StgCse after unarisation]
+~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+Consider two unboxed sum terms:
+
+ (# 1 | #) :: (# Int | Int# #)
+ (# 1 | #) :: (# Int | Int #)
+
+These two terms are not equal as they unarise to different unboxed
+tuples. However if we run StgCse before Unarise, it'll think the two
+terms (# 1 | #) are equal, and replace one of these with a binder to
+the other. That's bad -- Trac #15300.
+
+Solution: do unarise first.
+
-}
+
module StgCse (stgCse) where
import GhcPrelude