GHC-7.8 warning on rules that may not fire

With GHC-7.8 I get lots of warnings like src/Foo/Bar.hs:215:6: Warning: Rule "foo" may never fire because ‘bar’ might inline first Probable fix: add an INLINE[n] or NOINLINE[n] pragma on ‘bar’ So far I thought that rewrite RULES always have precedence to INLINE. Has this changed? I hesitate to follow the advice of adding phase numbers in bracket because I consider these phase numbers a quite fragile and non-modular solution (like precedence numbers for infix operators). I have found: https://ghc.haskell.org/trac/ghc/wiki/Plugins/Phases Is this still considered for future developments?

You may think they are fragile, but not as fragile as saying nothing and hoping for the best, which is *super*-fragile. You can't rely on rules to take priority, because the rule only fires if it matches, and it may only match if some other inlining has taken place. (We tried that originally.) I don't have any plans to change this, but of course am always open to well-worked out design proposals. Simon | -----Original Message----- | From: Glasgow-haskell-users [mailto:glasgow-haskell-users- | bounces@haskell.org] On Behalf Of Henning Thielemann | Sent: 14 March 2014 16:57 | To: GHC Users List | Subject: GHC-7.8 warning on rules that may not fire | | With GHC-7.8 I get lots of warnings like | | src/Foo/Bar.hs:215:6: Warning: | Rule "foo" may never fire | because ‘bar’ might inline first | Probable fix: add an INLINE[n] or NOINLINE[n] pragma on ‘bar’ | | So far I thought that rewrite RULES always have precedence to INLINE. | Has this changed? I hesitate to follow the advice of adding phase | numbers in bracket because I consider these phase numbers a quite | fragile and non-modular solution (like precedence numbers for infix | operators). | | I have found: | https://ghc.haskell.org/trac/ghc/wiki/Plugins/Phases | | Is this still considered for future developments? | _______________________________________________ | Glasgow-haskell-users mailing list | Glasgow-haskell-users@haskell.org | http://www.haskell.org/mailman/listinfo/glasgow-haskell-users

Am 14.03.2014 18:05, schrieb Simon Peyton Jones:
You may think they are fragile, but not as fragile as saying nothing and hoping for the best, which is *super*-fragile. You can't rely on rules to take priority, because the rule only fires if it matches, and it may only match if some other inlining has taken place. (We tried that originally.)
Ok, how shall I choose "n" in "INLINE[n]"? Is there a meaning of the phase numbers? I guess it is important to adhere to some conventions in order to work together with other libraries. If I understand correctly I can alter the number of phases with the -fsimplifier-phases option - how can I choose phase numbers for INLINE that are universally reasonable?

The simplifier runs with phase 2, then 1 then 0 (multiple times). Generally you want to make sure that something does not inline before its RULE can fire. There are quite a few examples in the base package, if you grep for RULE Simon | -----Original Message----- | From: Henning Thielemann [mailto:lemming@henning-thielemann.de] | Sent: 14 March 2014 17:27 | To: Simon Peyton Jones; GHC Users List | Subject: Re: GHC-7.8 warning on rules that may not fire | | Am 14.03.2014 18:05, schrieb Simon Peyton Jones: | | > You may think they are fragile, but not as fragile as saying nothing | > and hoping for the best, which is *super*-fragile. You can't rely on | > rules to take priority, because the rule only fires if it matches, and | > it may only match if some other inlining has taken place. (We tried | > that originally.) | | Ok, how shall I choose "n" in "INLINE[n]"? Is there a meaning of the | phase numbers? I guess it is important to adhere to some conventions in | order to work together with other libraries. | | If I understand correctly I can alter the number of phases with the - | fsimplifier-phases option - how can I choose phase numbers for INLINE | that are universally reasonable?
participants (2)
-
Henning Thielemann
-
Simon Peyton Jones