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

GHC ghc-devs at haskell.org
Tue Oct 14 08:01:58 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 simonpj):

 Well, when a table-driven jump doesn't work GHC generates a binary tree,
 reverting a table-driven jump whenever it finds a sufficiently dense
 patch.  (I'm not sure this is fully done, but that's the intention.)  Even
 if there are no dense patches, log(N) is better than N.

 For the second point, I'm suggesting that the `litEq` rule should apply
 only when the result of the comparison is immediately scrutinised by a
 `case`.

 I don't really understand Reid's proposal but it looks dangerously fragile
 to me.  Apart from anything else it sounds as if the programmer has to
 think about two different equality operations; and that which to use
 depends on context.  But the context can change radically after inlining.
 It smells bad to me, but I'm open to persuasion.

 Meanwhile I think changing `litEq` as I suggest would do a nice job. I
 could be wrong about that too, but it's my working hypothesis.

 Simon

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


More information about the ghc-tickets mailing list