[GHC] #14211: Compiler is unable to INLINE as well as the programmer can manually
GHC
ghc-devs at haskell.org
Sun Sep 10 17:25:53 UTC 2017
#14211: Compiler is unable to INLINE as well as the programmer can manually
-------------------------------------+-------------------------------------
Reporter: harendra | Owner: (none)
Type: bug | Status: new
Priority: normal | Milestone:
Component: Compiler | Version: 8.2.1
Resolution: | Keywords:
| StaticArgumentTransformation,
| Inlining
Operating System: Unknown/Multiple | Architecture:
Type of failure: Runtime | Unknown/Multiple
performance bug | Test Case:
Blocked By: | Blocking:
Related Tickets: | Differential Rev(s):
Wiki Page: |
-------------------------------------+-------------------------------------
Comment (by harendra):
That information is a gem for optimization! I need to change how I code
recursive functions. Every programmer must know that a static argument
impacts performance significantly and can be easily optimized. It not only
recovered the lost performance but gave a lot more because the manually
inlined bind function also has a static argument which got removed in this
version.
I think the problem is not really inlining. GHC won't be able to inline
the recursive call of a function to itself, of course, but it can still
inline the whole function. So `bindWith` is likely getting inlined, I can
see that with `-ddump-inlinings`. I guess, the problem is that we have
added one more static argument which degrades the performance. The
compiler is able to inline the function but it cannot undo that static
argument.
I see that the INLINE section in the GHC manual mentions mutually
recursive and recursive functions, however it does not mention `-fstatic-
argument-transformation`. It may be useful to mention because the
programmer naively expects that inlining will give us equivalent code but
in reality the added static argument is an overhead that cannot be
reverted by the compiler.
I have a few questions, suggestions:
1) The INLINE section of the manual should mention `-fstatic-argument-
transformation` and how factoring out of code can add a static argument
that cannot be undone by the compiler unless we use this option. Also, an
example of how the programmer can manually perform static argument
transformation and achieve what (s)he wants in case this option does not
work.
2) Can we have a warning option which warns the programmer about missed
inlining? If I have placed an INLINE pragma and the compiler is unable to
inline the function for whatever reason I want to know. The `-ddump-
inlinings` shows what got inlined but what did not get inlined will be
more useful information.
--
Ticket URL: <http://ghc.haskell.org/trac/ghc/ticket/14211#comment:2>
GHC <http://www.haskell.org/ghc/>
The Glasgow Haskell Compiler
More information about the ghc-tickets
mailing list