[GHC] #13422: INLINE CONLIKE sometimes fails to inline

GHC ghc-devs at haskell.org
Tue Apr 4 03:27:45 UTC 2017


#13422: INLINE CONLIKE sometimes fails to inline
-------------------------------------+-------------------------------------
        Reporter:  dfeuer            |                Owner:  (none)
            Type:  bug               |               Status:  new
        Priority:  normal            |            Milestone:  8.4.1
       Component:  Compiler          |              Version:  8.1
      Resolution:                    |             Keywords:
Operating System:  Unknown/Multiple  |         Architecture:
 Type of failure:  Runtime           |  Unknown/Multiple
  performance bug                    |            Test Case:
      Blocked By:                    |             Blocking:
 Related Tickets:  #7206             |  Differential Rev(s):
       Wiki Page:                    |
-------------------------------------+-------------------------------------

Comment (by bgamari):

 I've quickly looked at this and it seems that one crucial difference is
 that when `n` is banged the first phase simplifier considers it to be a
 `ValueArg` as it has a conlike unfolding, whereas without it is merely `
 TrivialArg`.

 At first simplification proceeds similarly in both cases,
  * `$fEnumInt_$cenumFromTo`
  * `sum` is inlined (the unfolding of which contains a `foldl`). It is
 interesting to note that the list argument is considered to be a
 `ValueArg` with the bang, but a `TrivialArg` without.
  * `foldl` is inlined
  * `$fNumInt_$cfromInteger` is inlined

 This is where the two programs diverge. While the `fold/cheapBuild` rule
 fires in the banged case, it fails to fire on the unbanged program. After
 that point, things obviously proceed much differently. While `cheapBuild`
 itself is eventually inlined in the unbanged version, it the fusion rule
 never fires.

 This is rather curious since,
  * the desugared core is identical between the banged and unbanged case
  * the performed inlinings are identical

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


More information about the ghc-tickets mailing list