INLINE pragma semantics changed since 8.0.2
It now seems that unfoldings for INLINE things are optimised slightly. This causes different interactions with RULES
than before.
module A where
{-# INLINE f #-}
f x = h x
h x = x
{-# RULES "h x" forall x . h x = error "REWRITE" #-}
module B where
import A
qux = f 5
Then running
> ghc-8.0.2 B.hs -O2 -fforce-recomp -ddump-simpl | grep qux -A5
qux :: Integer
[GblId, Str=DmdType x]
qux =
error ....
> ghc-8.2.0.20170507 B.hs -O2 -fforce-recomp -ddump-simpl | grep qux -A5
qux :: Integer
[GblId,
Caf=NoCafRefs,
Unf=Unf{Src=<vanilla>, TopLvl=True, Value=True, ConLike=True,
WorkFree=True, Expandable=True, Guidance=IF_ARGS [] 100 0}]
qux = 5
Inspecting the unfoldings, we see that 8.2 optimises the unfoldings to inline h
before the rule can apply.
d61439f58ce9c5a268304423a43b9b44
f :: p -> p
{- Arity: 1, HasNoCafRefs, Strictness: <S,1*U>,
Inline: (sat-args=1),
Unfolding: InlineRule (1, False, True) (\ @ p (x :: p) -> x) -}
Is this new behaviour intentional? It seems possible that it will break some programs which use rewrite rules.
Trac metadata
Trac field | Value |
---|---|
Version | 8.0.1 |
Type | Bug |
TypeOfFailure | OtherFailure |
Priority | normal |
Resolution | Unresolved |
Component | Compiler |
Test case | |
Differential revisions | |
BlockedBy | |
Related | |
Blocking | |
CC | |
Operating system | |
Architecture |