[GHC] #9342: Branchless arithmetic operations

GHC ghc-devs at haskell.org
Sat Sep 26 18:22:53 UTC 2015


#9342: Branchless arithmetic operations
-------------------------------------+-------------------------------------
        Reporter:  hvr               |                Owner:
            Type:  feature request   |               Status:  new
        Priority:  normal            |            Milestone:  8.0.1
       Component:  Compiler          |              Version:  7.8.3
  (CodeGen)                          |
      Resolution:                    |             Keywords:
Operating System:  Unknown/Multiple  |         Architecture:
                                     |  Unknown/Multiple
 Type of failure:  None/Unknown      |            Test Case:
      Blocked By:                    |             Blocking:
 Related Tickets:                    |  Differential Rev(s):
-------------------------------------+-------------------------------------

Comment (by strake888):

 On my AMD FX-8320, branchless `abs` and `sgn` seem speedier but branchless
 `cmp` seems slower:

 {{{
 $ ./bench 'abs '
 benchmarking abs
 time                 37.06 ms   (36.60 ms .. 37.56 ms)
                      1.000 R²   (0.999 R² .. 1.000 R²)
 mean                 37.99 ms   (37.68 ms .. 38.37 ms)
 std dev              676.9 μs   (490.1 μs .. 926.6 μs)

 $ ./bench 'abs'''
 benchmarking abs'
 time                 34.41 ms   (33.97 ms .. 34.77 ms)
                      1.000 R²   (0.999 R² .. 1.000 R²)
 mean                 34.08 ms   (33.95 ms .. 34.25 ms)
 std dev              307.3 μs   (243.0 μs .. 418.2 μs)

 $ ./bench 'sgn '
 benchmarking sgn
 time                 36.70 ms   (36.33 ms .. 37.10 ms)
                      1.000 R²   (0.999 R² .. 1.000 R²)
 mean                 36.93 ms   (36.79 ms .. 37.03 ms)
 std dev              216.7 μs   (127.8 μs .. 343.1 μs)

 $ ./bench 'sgn'''
 benchmarking sgn'
 time                 34.60 ms   (34.24 ms .. 34.92 ms)
                      1.000 R²   (0.999 R² .. 1.000 R²)
 mean                 34.18 ms   (34.02 ms .. 34.36 ms)
 std dev              348.1 μs   (263.4 μs .. 461.5 μs)

 $ ./bench 'cmp '
 benchmarking cmp
 time                 35.80 ms   (35.04 ms .. 36.80 ms)
                      0.998 R²   (0.996 R² .. 0.999 R²)
 mean                 36.79 ms   (36.32 ms .. 37.15 ms)
 std dev              875.3 μs   (665.6 μs .. 1.178 ms)

 $ ./bench 'cmp'''
 benchmarking cmp'
 time                 36.41 ms   (35.72 ms .. 37.08 ms)
                      0.999 R²   (0.998 R² .. 1.000 R²)
 mean                 36.44 ms   (35.96 ms .. 36.74 ms)
 std dev              726.9 μs   (513.8 μs .. 1.044 ms)

 $
 }}}

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


More information about the ghc-tickets mailing list