[GHC] #9661: Branchless ==# is compiled to branchy code
GHC
ghc-devs at haskell.org
Fri Oct 3 22:30:22 UTC 2014
#9661: Branchless ==# is compiled to branchy code
-------------------------------------+-------------------------------------
Reporter: dfeuer | Owner:
Type: feature | Status: new
request | Milestone:
Priority: normal | Version: 7.9
Component: Compiler | Keywords:
Resolution: | Architecture: Unknown/Multiple
Operating System: | Difficulty: Unknown
Unknown/Multiple | Blocked By:
Type of failure: Runtime | Related Tickets:
performance bug |
Test Case: |
Blocking: |
Differential Revisions: |
-------------------------------------+-------------------------------------
Comment (by rwbarton):
Replying to [comment:8 dfeuer]:
> With the exception of some bottom-of-the-stack `base` code with module
dependency nightmares, people who use such primops are usually trying to
do something specific for performance reasons, and we should be careful
not to interfere excessively if we can avoid doing so.
Everyone who uses `==` on `Int` is using `==#`, that was the point of my
Haskell `f` example above. Let's not lose track of the big picture here.
> Your preferred `==#` can be implemented in terms of mine, I believe,
like this:
>
> {{{#!hs
> bartonEq x y = case feuerEq x y of
> 1# -> 1#
> _ -> 0#
> }}}
>
> Going the other way around, however, is impossible. If you prefer, we
can give `feuerEq` a different name so current code will continue to work
the same.
I don't understand what `bartonEq` or `feuerEq` is or what the difference
between them is supposed to be. They look equal to me.
> > In any case, I would like to see some benchmarks showing that there
are performance gains to be had in real programs from control over
branchlessness before expending any effort on implementation.
>
> That ship has long since sailed—the massive breaking primBool change was
undertaken specifically to support this sort of thing.
No, it was undertaken to allow GHC to find better code to generate under
some circumstances. It was not undertaken to give the user control over
whether GHC produces branchless code or branching code.
--
Ticket URL: <http://ghc.haskell.org/trac/ghc/ticket/9661#comment:9>
GHC <http://www.haskell.org/ghc/>
The Glasgow Haskell Compiler
More information about the ghc-tickets
mailing list