[GHC] #759: RULES ignored by recompilation checker

GHC trac at galois.com
Mon May 1 21:54:16 EDT 2006


#759: RULES ignored by recompilation checker
-----------------------------------+----------------------------------------
    Reporter:  rl at cse.unsw.edu.au  |        Owner:         
        Type:  bug                 |       Status:  new    
    Priority:  normal              |    Milestone:         
   Component:  Compiler            |      Version:  6.4.2  
    Severity:  normal              |     Keywords:         
          Os:  Linux               |   Difficulty:  Unknown
Architecture:  x86                 |  
-----------------------------------+----------------------------------------
The recompilation checker does not seem to take RULES into account. This
 can lead to some really nasty optimisation bugs. A small example:

 {{{
 [rl at rl-lap stuff]$ cat T.hs
 module T where
 foo n = n+1
 {-# RULES
 "foo" forall n.
   foo (foo n) = foo (n+2)
 #-}

 [rl at rl-lap stuff]$ cat U.hs
 module Main where
 import T
 main = print $ foo (foo 5)

 [rl at rl-lap stuff]$ ghc --make U.hs -O
 Chasing modules from: U.hs
 Compiling T                ( ./T.hs, ./T.o )
 Compiling Main             ( U.hs, U.o )
 Linking ...
 }}}

 Change the rule in T.hs:

 {{{
 [rl at rl-lap stuff]$ cat T.hs
 module T where
 foo n = n+1
 {-# RULES
 "foo" forall n.
   foo (foo n) = foo (n+3)
 #-}

 [rl at rl-lap stuff]$ ghc --make U.hs -O
 Chasing modules from: U.hs
 Compiling T                ( ./T.hs, ./T.o )
 Skipping  Main             ( U.hs, U.o )
 Linking ...
 [rl at rl-lap stuff]$ ghc -c U.hs -O
 compilation IS NOT required
 }}}

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


More information about the Glasgow-haskell-bugs mailing list