#5237: Inefficient code generated for x^2
--------------------------------------+-------------------------------------
  Reporter:  scpmw                    |          Owner:                
      Type:  bug                      |         Status:  new           
  Priority:  normal                   |      Milestone:  7.4.1         
 Component:  libraries/base           |        Version:  7.0.3         
Resolution:                           |       Keywords:                
  Testcase:                           |      Blockedby:                
Difficulty:                           |             Os:  Linux         
  Blocking:                           |   Architecture:  x86_64 (amd64)
   Failure:  Runtime performance bug  |  
--------------------------------------+-------------------------------------

Comment(by simonpj):

 Actually I realise that we already have a good mechanism for
 prioritisation: namely the simplifer's "phases".

  * If you want a RULE to match on a function, you had better make sure the
 function doesn't inline too early.  Typically use a NOINLINE pragma:
 {{{
 {-# RULE forall x.  f [x] = blah #-}
 {-# NOINLINE [1] f #-}
 f x = ...blah2...
 }}}

  * The simplifier works in phases, currently phase 2, then 1, then 0.  The
 RULE  is always active.  The NOINLINE stops f inlining until phase 1.  So
 the rule gets a chance to fire in the earlier phase 2.

  * You can attach phases to rules too, which say in which phases they are
 active.  Ditto SPECIALISE pragmas

  * GHC automatically generates specialisations for overloaded functions.
 The consequent rules are active precisely when the original function's
 INLINE pragma (if any) is active.  So if you say `NONLINE [1] f`, then any
 automatically generated specialisations of f will be active only in phase
 1 and later.

 Does that give you enough to go on?

 Simon

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

_______________________________________________
Glasgow-haskell-bugs mailing list
[email protected]
http://www.haskell.org/mailman/listinfo/glasgow-haskell-bugs

Reply via email to