[GHC] #14830: Use test instead of cmp for comparison against zero.

GHC ghc-devs at haskell.org
Tue Feb 20 16:28:11 UTC 2018


#14830: Use test instead of cmp for comparison against zero.
-------------------------------------+-------------------------------------
           Reporter:  AndreasK       |             Owner:  (none)
               Type:  task           |            Status:  new
           Priority:  low            |         Milestone:
          Component:  Compiler       |           Version:
  (NCG)                              |
           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:
-------------------------------------+-------------------------------------
 For comparisons `test r, r` and `cmp r, $0` are interchangeable at least
 on x86.

 However using test leads to slightly smaller code. (Saves a byte per
 comparison).

 A good starting point is stmtToInstrs in compiler/nativeGen/X86/CodeGen
 starting with how CmmCondBranch is compiled to Instructions.

 From there it should be not too hard to track down the required changes.

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


More information about the ghc-tickets mailing list