[GHC] #9661: Branchless ==# is compiled to branchy code

GHC ghc-devs at haskell.org
Sun Apr 19 17:10:54 UTC 2015


#9661: Branchless ==# is compiled to branchy code
-------------------------------------+-------------------------------------
        Reporter:  dfeuer            |                   Owner:  bgamari
            Type:  feature request   |                  Status:  new
        Priority:  normal            |               Milestone:
       Component:  Compiler          |                 Version:  7.9
      Resolution:                    |                Keywords:
Operating System:  Unknown/Multiple  |            Architecture:
 Type of failure:  Runtime           |  Unknown/Multiple
  performance bug                    |               Test Case:
      Blocked By:                    |                Blocking:
 Related Tickets:                    |  Differential Revisions:  D854
-------------------------------------+-------------------------------------

Comment (by rwbarton):

 Again there is a distinction between the compiler being able to generate
 branchless code and the compiler giving the user control over whether to
 generate branchless code. For example in that benchmark, it would be even
 better if the user could simply write

 {{{
         let inc     = if v >= 0 then 1 else 0
 }}}

 rather than

 {{{
         let !(I# v) = x
             inc     = I# (v >=$# 0#)
 }}}

 Any optimizing C compiler would avoid a branch in a function like

 {{{
 int g(int a, int b)
 {
   if (a >= 0)
     return b + 1;
   else
     return b;
 }
 }}}

 So, this isn't an example of the kind that I am talking about.

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


More information about the ghc-tickets mailing list