
#9013: plusWord2# is buggy -------------------------------------+------------------------------------ Reporter: pumpkin | Owner: Type: bug | Status: new Priority: normal | Milestone: Component: Compiler | Version: 7.8.2 Resolution: | Keywords: Operating System: Unknown/Multiple | Architecture: Unknown/Multiple Type of failure: None/Unknown | Difficulty: Unknown Test Case: | Blocked By: Blocking: | Related Tickets: -------------------------------------+------------------------------------ Comment (by rwbarton): Simon: `MO_Add2` is translated to an `ADD` (which is expected to either set or clear the carry flag as appropriate) followed by an `ADC`. Printing the `ADD` as (in this case) `dec` rather than `add` loses the effect on the carry flag, so the subsequent `ADC` will just use whatever garbage happens to be in the carry flag. Like Simon, I'm not totally thrilled with the organization of the code here, but one simple fix would be to add an `ADD'` instruction which means the same as `ADD` except it indicates that the side effect of setting the carry flag is important. Then the pretty printer can produce `dec` for an `ADD` of `-1` but not for an `ADD'` of `-1`. GHC doesn't expose the carry flag to Haskell directly so we would only need to use `ADD'` in the translation of `MO_Add2` and other similar operations. -- Ticket URL: http://ghc.haskell.org/trac/ghc/ticket/9013#comment:6 GHC http://www.haskell.org/ghc/ The Glasgow Haskell Compiler