CORE notes break optimisation
I think at some point we decided that Core notes shouldn't affect optimisation. Here is a case where they do:
module Foo where
foo :: Int -> Int
{-# INLINE [1] foo #-}
foo x = x+1
{-# RULES "foo/foo" forall x. foo (foo x) = x #-}
module Bar where
import Foo
bar :: Int -> Int -> Int
bar x y = foo ({-# CORE "note" #-} x `seq` foo y)
When compiled with -O2, the rule doesn't fire with the note but does fire without it. This is the Core with the note:
Bar.bar =
\ (x_aaw :: GHC.Types.Int) (y_aax :: GHC.Types.Int) ->
Foo.foo
(__core_note "note"
(case x_aaw of _ { GHC.Types.I# _ -> Foo.foo y_aax }))
For the rule to fire, GHC must move the seq to the outside but because of the note, it doesn't.
Trac metadata
| Trac field | Value |
|---|---|
| Version | 7.1 |
| Type | Bug |
| TypeOfFailure | OtherFailure |
| Priority | normal |
| Resolution | Unresolved |
| Component | Compiler |
| Test case | |
| Differential revisions | |
| BlockedBy | |
| Related | |
| Blocking | |
| CC | |
| Operating system | |
| Architecture |