[GHC] #8472: Primitive string literals prevent optimization

GHC ghc-devs at haskell.org
Fri Oct 25 13:59:15 UTC 2013


#8472: Primitive string literals prevent optimization
--------------------------------------------+------------------------------
        Reporter:  akio                     |            Owner:
            Type:  bug                      |           Status:  new
        Priority:  normal                   |        Milestone:
       Component:  Compiler                 |          Version:  7.6.3
      Resolution:                           |         Keywords:
Operating System:  Linux                    |     Architecture:  x86_64
 Type of failure:  Runtime performance bug  |  (amd64)
       Test Case:                           |       Difficulty:  Unknown
        Blocking:                           |       Blocked By:
                                            |  Related Tickets:
--------------------------------------------+------------------------------

Comment (by simonpj):

 Great example.  It's an example of #2840.

 The problem is that we get something like this:
 {{{
 f = let a::Addr# = "foo"#
     in \x -> blah

 g y = ...(f e)...
 }}}
 We can't float the binding for `a` to the top level because Core doesn't
 allow top-level bindings.  But by not floating it we prevent `f` being
 inlined, which is pretty terrible.

 I think the solution is simply to '''allow top level bindings of form
 `a::Addr# = "foo"#`'''.
 That is:
  * The type is `Addr#`
  * The RHS is a string literal; in particular NOT a string computation

 Things that would need doing:
  * Modify the test `isUnLiftedType ty` in `SetLevels.lvlMFE`, which stops
 unlifted things getting floated to top level.
  * Similarly `Simplify.bindingOk`.
  * Make `CmmLint` check the new invariant.
  * The STG->Cmm code generator would need to generate some suitable
 `CmmData` stuff.

 This is a fairly easy job. Any volunteers?

 Simon

--
Ticket URL: <http://ghc.haskell.org/trac/ghc/ticket/8472#comment:1>
GHC <http://www.haskell.org/ghc/>
The Glasgow Haskell Compiler


More information about the ghc-tickets mailing list