[GHC] #7367: Optimiser / Linker Problem on amd64

GHC ghc-devs at haskell.org
Tue Aug 27 01:11:38 UTC 2013


#7367: Optimiser / Linker Problem on amd64
--------------------------------------------+------------------------------
        Reporter:  wurmli                   |            Owner:
            Type:  bug                      |           Status:  new
        Priority:  normal                   |        Milestone:  7.8.1
       Component:  Build System             |          Version:  7.6.1
      Resolution:                           |         Keywords:
Operating System:  Linux                    |     Architecture:  x86_64
 Type of failure:  Runtime performance bug  |  (amd64)
       Test Case:                           |       Difficulty:  Unknown
        Blocking:                           |       Blocked By:
                                            |  Related Tickets:
--------------------------------------------+------------------------------

Comment (by rwbarton):

 Based on an examination of the Core, GHC HEAD (and presumably 7.6 though I
 don't have it to test) is floating the expression `i .&. 1 == 0` out of
 `\f -> ...` in `checksum`, resulting in the allocation of a thunk per
 execution of the `go`/`upd` loop in `genPermutations`.  GHC 7.4 doesn't
 perform this "optimization" in this particular program.  Not sure why.

 The allocations under GHC HEAD can be eliminated with a change to the
 benchmark program like this:

 {{{
 --- f-orig.hs   2013-08-26 19:42:27.000000000 -0400
 +++ f.hs        2013-08-26 19:30:09.000000000 -0400
 @@ -64,11 +64,11 @@
                 if p0 == 0 then increment perm count >> run f else do
                         copyArray destF perm n
                         increment perm count
 -                       flopS destF $ \ flops ->
 -                               run (f `mappend` F (checksum j flops)
 flops)
 +                        if j .&. 1 == 0
 +                          then flopS destF $ \ flops -> run (f `mappend`
 F flops flops)
 +                          else flopS destF $ \ flops -> run (f `mappend`
 F (-flops) flops)
         let go j !f = if j >= r then return f else upd j f (go (j+1))
         go l mempty
 - where checksum i f = if i .&. 1 == 0 then f else -f
 }}}

 **or** by building with `-fno-full-laziness` provided that `flopp` and
 `swap` are moved out of `flop` to the top level (otherwise, those allocate
 instead).

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




More information about the ghc-tickets mailing list