[GHC] #12618: Add saturated constructor applications to Core

GHC ghc-devs at haskell.org
Fri Oct 7 20:57:26 UTC 2016


#12618: Add saturated constructor applications to Core
-------------------------------------+-------------------------------------
        Reporter:  simonpj           |                Owner:  nomeata
            Type:  feature request   |               Status:  new
        Priority:  normal            |            Milestone:
       Component:  Compiler          |              Version:  8.0.1
      Resolution:                    |             Keywords:
Operating System:  Unknown/Multiple  |         Architecture:
                                     |  Unknown/Multiple
 Type of failure:  None/Unknown      |            Test Case:
      Blocked By:                    |             Blocking:
 Related Tickets:                    |  Differential Rev(s):
       Wiki Page:                    |
-------------------------------------+-------------------------------------

Comment (by simonpj):

 Actually this is already a problem today. It's just rendered more
 prominent now that even `(:)` has a wrapper.  Consider
 {{{
 data T = MkT {-# UNPACK #-} !Int

 {-# RULES

 "fT" f MkT = True
 "gT" forall x. g (MkT x) = x
   #-}

 f :: (Int -> T) -> Bool
 {-# NOINLINE f #-}
 f x = True

 g :: T -> Int
 {-# NOINLINE g #-}
 g (MkT x) = x+1
 }}}
 yields
 {{{
 Foo.hs:9:1: warning: [-Winline-rule-shadowing]
     Rule "fT" may never fire because 'Foo.$WMkT' might inline first
     Probable fix: add an INLINE[n] or NOINLINE[n] pragma for 'Foo.$WMkT'

 Foo.hs:10:1: warning: [-Winline-rule-shadowing]
     Rule "gT" may never fire because 'Foo.$WMkT' might inline first
     Probable fix: add an INLINE[n] or NOINLINE[n] pragma for 'Foo.$WMkT'
 }}}
 What to do?  If we are to match these rules, we really must delay inlining
 the wrapper for `MkT` (after inlining we get a mess of unboxing etc).
 So either we must allow you to add a NOINLINE pragma to `MkT`; or
 we must add one automatically (e.g. `NOINLINE [1]`).

 Delaying all consructor-wrapper inlining to phase 1 is potentially
 quite drastic, because case-of-known-constructor wouldn't happen until
 the wrappers are inlined.  Maybe that's ok; I'm not sure.  Worth trying I
 think.

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


More information about the ghc-tickets mailing list