[GHC] #9136: Constant folding in Core could be better

GHC ghc-devs at haskell.org
Fri May 23 11:10:17 UTC 2014


#9136: Constant folding in Core could be better
--------------------------------------------+------------------------------
        Reporter:  simonpj                  |            Owner:
            Type:  bug                      |           Status:  new
        Priority:  normal                   |        Milestone:
       Component:  Compiler                 |          Version:  7.8.2
      Resolution:                           |         Keywords:
Operating System:  Unknown/Multiple         |     Architecture:
 Type of failure:  Runtime performance bug  |  Unknown/Multiple
       Test Case:                           |       Difficulty:  Unknown
        Blocking:                           |       Blocked By:
                                            |  Related Tickets:
--------------------------------------------+------------------------------

Comment (by nomeata):

 >  The difficulty is knowing where to stop. What about `(8 +# x) -# 1`?

 Surely there must be standard solutions in (non-functional) compilers. I
 asked the compiler guys next door and they pointed me to Muchnick’s
 Advanced Compiler Design & Implementation, where Fig 12.6 lists 20
 transformation rules which should move constants in an expression
 involving `+`, `-` and `*` together and combine the constants.
 [http://stackoverflow.com/questions/23827531/reassociation-according-to-
 muchnick I don’t understand them yet], but something along these lines
 would work well.

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


More information about the ghc-tickets mailing list