
I wonder if a better approach would be a STG-level CSE pass? (No types
#9291: Don't reconstruct sum types if the type subtly changes
-------------------------------------+-------------------------------------
Reporter: schyler | Owner:
Type: feature request | Status: new
Priority: normal | Milestone:
Component: Compiler | Version: 7.8.2
Resolution: | Keywords:
Operating System: Unknown/Multiple | Architecture:
Type of failure: Runtime | Unknown/Multiple
performance bug | Test Case:
Blocked By: | Blocking:
Related Tickets: | Differential Rev(s):
Wiki Page: |
-------------------------------------+-------------------------------------
Comment (by nomeata):
there!)
Is general CSE on the STG level safe? We would have to pay attention not
to CSE two invocations of `newSTRef`, for example! Consider
{{{#!hs
foo :: Integer -> Integer
foo n = runST (newSTRef 1 >>= \r -> modifySTRef r (+n) >> readSTRef r)
+ runST (newSTRef 1 >>= \r -> modifySTRef r (+2*n) >> readSTRef r)
}}}
which generated this STG
{{{
STGCSE.foo :: GHC.Integer.Type.Integer -> GHC.Integer.Type.Integer
[GblId, Arity=1, Str=