[GHC] #9013: plusWord2# is buggy

GHC ghc-devs at haskell.org
Mon Aug 11 08:40:19 UTC 2014


#9013: plusWord2# is buggy
-------------------------------------+-------------------------------------
              Reporter:  pumpkin     |            Owner:
                  Type:  bug         |           Status:  new
              Priority:  normal      |        Milestone:
             Component:  Compiler    |          Version:  7.8.2
            Resolution:              |         Keywords:
      Operating System:              |     Architecture:  Unknown/Multiple
  Unknown/Multiple                   |       Difficulty:  Unknown
       Type of failure:              |       Blocked By:
  None/Unknown                       |  Related Tickets:
             Test Case:              |
              Blocking:              |
Differential Revisions:  Phab:D137   |
-------------------------------------+-------------------------------------

Comment (by simonmar):

 I've accepted @rwbarton's diff.

 > Surely it'd be better for some earlier phase to optimise (plusWord# x
 (-1)) to (minusWord# x 1)

 The problem is that this would only catch instructions that arise from
 those particular primops, not any other instructions.  Add instructions
 arise for lots of reasons, even during native code generation itself.

 The reason the peephole is done very late is
  * We don't need explicit inc/dec instructions in the data type
  * We catch all the opportunities.  Anything else would run the risk of
 any subsequent optimisation passes leaving opportunities behind.  A smart
 constructor would work but also runs the risk that you might forget to use
 it somewhere.

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


More information about the ghc-tickets mailing list