Skip to content

Commit

Permalink
Add comments for StgCse and Unarise
Browse files Browse the repository at this point in the history
This just improves docmentation for the fix to Trac #15300
  • Loading branch information
Simon Peyton Jones committed Oct 25, 2018
1 parent a3476aa commit 232b0cb
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 0 deletions.
2 changes: 2 additions & 0 deletions compiler/simplStg/SimplStg.hs
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
16 changes: 16 additions & 0 deletions compiler/simplStg/StgCse.hs
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit 232b0cb

Please sign in to comment.