[GHC] #5615: ghc produces poor code for `div` with constant powers of 2.

GHC ghc-devs at haskell.org
Sun Sep 21 00:05:15 UTC 2014


#5615: ghc produces poor code for `div` with constant powers of 2.
-------------------------------------+-------------------------------------
              Reporter:  Lennart     |            Owner:  daniel.is.fischer
                  Type:  bug         |           Status:  new
              Priority:  normal      |        Milestone:  7.10.1
             Component:  Compiler    |          Version:  7.4.1-rc1
            Resolution:              |         Keywords:
      Operating System:              |     Architecture:  x86
  Unknown/Multiple                   |       Difficulty:  Unknown
       Type of failure:              |       Blocked By:
  None/Unknown                       |  Related Tickets:
             Test Case:              |
              Blocking:              |
Differential Revisions:              |
-------------------------------------+-------------------------------------

Comment (by dfeuer):

 Replying to [comment:17 thomie]:

 Here's an updated link to [http://research.microsoft.com/pubs/151917
 /divmodnote-letter.pdf Daan Leijen's paper]. Euclidean div/mod, along with
 other benefits, works much better than Haskell div/mod with the idea I've
 been playing with of implementing `div`-like things and `mod`-like things
 using `divMod`-like things. In particular, CSE can do some really nifty
 stuff with either `quotRem` or `divModEuclidean`, but it has no hope with
 `divMod` (at least as it's currently implemented) in the general case,
 because the latter has complicated code that gets all torn up before it
 gets to CSE. I don't know if there's a way to fix that. It does work out
 if one or both of the operands is known and there's sufficient inlining.

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


More information about the ghc-tickets mailing list