[GHC] #12982: Missed constant folding oportunities

GHC ghc-devs at haskell.org
Thu Dec 15 07:45:30 UTC 2016


#12982: Missed constant folding oportunities
-------------------------------------+-------------------------------------
           Reporter:  erikd          |             Owner:
               Type:  feature        |            Status:  new
  request                            |
           Priority:  normal         |         Milestone:  8.4.1
          Component:                 |           Version:  8.0.1
  libraries/hoopl                    |
           Keywords:                 |  Operating System:  Unknown/Multiple
       Architecture:                 |   Type of failure:  None/Unknown
  Unknown/Multiple                   |
          Test Case:                 |        Blocked By:
           Blocking:                 |   Related Tickets:
Differential Rev(s):                 |         Wiki Page:
-------------------------------------+-------------------------------------
 A work colleague of mine found that some expressions were not being
 constant folded as expected.

 For example:
 {{#!hs
 module Test where
 import Data.Int
 number :: Int64
 number = 2 ^ 10 - 3
 }}}
 compiled using:
 {{{
 ghc -O2 -keep-s-file -c test.hs
 }}}
 should result in an assembler file containing the constant `1021` but
 doesn't. However, if I change the above expression to:

 {{{
 number = 1024 -3
 }}}
 then the output assembler files does contain the value `1021`.

 I did a bit of a search and found some constant folding code in the
 `hoopl` library, but that doesn't seem to be what GHC actually uses.

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


More information about the ghc-tickets mailing list