[GHC] #9661: Branchless ==# is compiled to branchy code
GHC
ghc-devs at haskell.org
Fri Oct 3 08:15:10 UTC 2014
#9661: Branchless ==# is compiled to branchy code
-------------------------------------+-------------------------------------
Reporter: dfeuer | Owner:
Type: bug | Status: new
Priority: normal | Milestone:
Component: Compiler | Version: 7.9
Resolution: | Keywords:
Operating System: | Architecture: Unknown/Multiple
Unknown/Multiple | Difficulty: Unknown
Type of failure: Runtime | Blocked By:
performance bug | Related Tickets:
Test Case: |
Blocking: |
Differential Revisions: |
-------------------------------------+-------------------------------------
Comment (by jstolarek):
After some thinking I don't think it's constant folding but more generally
the special rules for `==#`. As promised here are some hints how to get
started on this one:
1. Try to reproduce the problem with a simpler example, eg. using only two
comparison primops and `orI#`. Try out different combinations of
comparison primops. See also whether this happens for `andI#`. We want to
be sure that this only depends on presence of `==#` and not other
operators (don't forget `/=#`).
2. Once you have a smaller test case follow the transformation that GHC is
performing to arrive at the result. Is it turning the simpler test case
into the final result in one step or are there any intermediate steps?
3. My guess would be that the culprit is `litEq` function in
`PrelRules.lhs` module. The comment above it claims to do exactly what
you've reported here. However, I'm not sure what the fix should be.
Disabling this is probably not a good idea, since in some cases we really
want that transformation to happen. We'd need to think more but first
let's confirm whether `litEq` is the cause or not. You can verify that by
disabling that rule and seeing whether the code compiles without branches.
--
Ticket URL: <http://ghc.haskell.org/trac/ghc/ticket/9661#comment:1>
GHC <http://www.haskell.org/ghc/>
The Glasgow Haskell Compiler
More information about the ghc-tickets
mailing list