#5059: Pragma to SPECIALISE on value arguments
---------------------------------+------------------------------------------
    Reporter:  batterseapower    |       Owner:                  
        Type:  feature request   |      Status:  new             
    Priority:  low               |   Milestone:  7.6.1           
   Component:  Compiler          |     Version:  7.0.3           
    Keywords:                    |          Os:  Unknown/Multiple
Architecture:  Unknown/Multiple  |     Failure:  None/Unknown    
  Difficulty:  Unknown           |    Testcase:                  
   Blockedby:                    |    Blocking:                  
     Related:                    |  
---------------------------------+------------------------------------------
Changes (by simonpj):

 * cc: johan.tibell@… (added)
  * difficulty:  => Unknown


Comment:

 Johan Tibell writes: While looking at the
 [http://gcc.gnu.org/gcc-4.7/changes.html GCC 4.7 release notes] I saw
 something that's perhaps worth stealing. Taken from the release notes:
 {{{
     The inter-procedural constant propagation pass has been rewritten. It
     now performs generic function specialization. For example when
     compiling the following:

     void foo(bool flag)
     {
       if (flag)
         ... do something ...
       else
         ... do something else ...
     }
     void bar (void)
     {
       foo (false);
       foo (true);
       foo (false);
       foo (true);
       foo (false);
       foo (true);
     }


     GCC will now produce two copies of foo. One with flag being true,
     while other with flag being false. This leads to performance
     improvements previously possibly only by inlining all calls. Cloning
     causes a lot less code size growth.
 }}}
 I found myself wanting something like this just today. A common pattern I
 see in code is this:
 {{{
     data Options = Options { ... }

     defaultOptions :: Options
     defaultOptions = ...

     foo :: ...
     foo = fooWith defaultOptions

     fooWith :: Options -> ...
     fooWith = ...
 }}}
 It'd be nice if we could get foo to specialize on its input arguments,
 without having to mark all of fooWith as INLINE.

 -- Johan

-- 
Ticket URL: <http://hackage.haskell.org/trac/ghc/ticket/5059#comment:13>
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