
#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: | -------------------------------------+------------------------------------- Comment (by rwbarton): In fact it's even more involved than I originally thought. `MO_Add2` invokes the code generator for `MO_Add` to do the first addition. `MO_Add` sees that the second argument is constant so it can produce an `LEA` instruction (which wouldn't set the carry flag). The pretty-printer notices that the source and destination registers of the `LEA` instruction are the same, so it rewrites it to an `ADD` (which would set the carry flag); and then it notices that the addend is -1, so it finally emits `dec` (which doesn't set the carry flag). All of what the code generator does for `MO_Add` is fine, since the semantics of `MO_Add` don't include any effect (or lack thereof) on the condition register. The error is in the code generation for `MO_Add2`: it should not use `MO_Add`, for this reason. I will put up a patch for review shortly. -- Ticket URL: http://ghc.haskell.org/trac/ghc/ticket/9013#comment:8 GHC http://www.haskell.org/ghc/ The Glasgow Haskell Compiler