patch applied (ghc): Attach the INLINE Activation pragma to any automatically-generated specialisations

Simon Peyton Jones simonpj at microsoft.com
Wed Jan 23 10:36:26 EST 2008


Wed Jan 23 05:40:12 PST 2008  simonpj at microsoft.com
  * Attach the INLINE Activation pragma to any automatically-generated specialisations
  
  Another idea suggested by Roman, happily involving a one-line change.  Here's 
  the new Note in Specialise:
  
  Note [Auto-specialisation and RULES]
  ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  Consider:
     g :: Num a => a -> a
     g = ...
  
     f :: (Int -> Int) -> Int
     f w = ...
     {-# RULE f g = 0 #-}
  
  Suppose that auto-specialisation makes a specialised version of
  g::Int->Int That version won't appear in the LHS of the RULE for f.
  So if the specialisation rule fires too early, the rule for f may
  never fire.
  
  It might be possible to add new rules, to "complete" the rewrite system.
  Thus when adding
  	RULE forall d. g Int d = g_spec
  also add
  	RULE f g_spec = 0
  
  But that's a bit complicated.  For now we ask the programmer's help,
  by *copying the INLINE activation pragma* to the auto-specialised rule.
  So if g says {-# NOINLINE[2] g #-}, then the auto-spec rule will also
  not be active until phase 2. 
  

    M ./compiler/specialise/Specialise.lhs -1 +29



More information about the Cvs-ghc mailing list