Ticket #5895 (closed bug: fixed)

Opened 15 months ago

Last modified 15 months ago

INLINE pragma doesn't trigger on locally defined function

Reported by: tibbe Owned by:
Priority: normal Milestone:
Component: Compiler Version: 7.4.1
Keywords: Cc:
Operating System: Unknown/Multiple Architecture: Unknown/Multiple
Type of failure: None/Unknown Difficulty: Unknown
Test Case: Blocked By:
Blocking: Related Tickets:

Description

I have a function on the form

f = ...g...
  where
    g = ...h...
    h = ...step...
      where step
        | ... = ...g...
        | ... = ...step...
    {-# INLINE h #-}
{-# INLINE f #-}

GHC refuses to inline h, even with an explicit INLINE pragma. I realize that h is part of a loop, g->h->step->g, but it seems to me that it should be possible to inline the non-recursive h anyway.

I've attached a standalone test case (which is a quite a bit longer.) The function f above corresponds to filterWithKey in the test case.

Attachments

Repro.hs Download (6.1 KB) - added by tibbe 15 months ago.

Change History

Changed 15 months ago by tibbe

Changed 15 months ago by simonpj@…

commit 90de9736adada919b50a9a2ce5aae136f64c75fe

Author: Simon Peyton Jones <simonpj@microsoft.com>
Date:   Sun Mar 4 08:18:09 2012 +0000

    Attach INLINE pagmas in mutually recursive bindings
    
    This should fix #5895.  It seems that I was silently
    ignoring INLINE pragmas in mutual recursion, which is
    not the right thing at all.

 compiler/deSugar/DsBinds.lhs |   31 +++++++++++++++++++++++++++++--
 compiler/hsSyn/HsBinds.lhs   |    8 ++++----
 2 files changed, 33 insertions(+), 6 deletions(-)

Changed 15 months ago by simonpj

  • status changed from new to closed
  • difficulty set to Unknown
  • resolution set to fixed

Thanks Johan, an excellent point. I believe I have fixed it now, although it's difficult to be 100% sure becuase your example is complicated. Would you like to check. I'll close, but re-open if you think it's still wrong.

Making a regression test seems difficult. So I haven't.

Simon

Note: See TracTickets for help on using tickets.