patch applied (ghc): Fix Trac #2581: inlining of record selectors
Simon Peyton Jones
simonpj at microsoft.com
Wed Sep 10 04:53:54 EDT 2008
Wed Sep 10 01:30:14 PDT 2008 simonpj at microsoft.com
* Fix Trac #2581: inlining of record selectors
Bryan discovered that a non-trivial record selector (non-trivial in
the sense that it has to reconstruct the result value because of
UNPACK directives) weren't being inlined. The reason was that the
unfolding generated by MkId.mRecordSelId was never being optimised
*at all*, and hence looked big, and hence wasn't inlined.
(The out-of-line version *is* put into the code of the module
and *is* optimised, which made this bug pretty puzzling. But the
unfolding inside the record-selector-Id itself, which is a GlobalId
and hence does not get its inlining updated like LocalIds, was
big and fat.)
Solution: I wrote a very simple optimiser, CoreUnfold.simplOptExpr,
which does enough optimisation to solve this particular problem.
It's short, simple, and will be useful in other contexts.
M ./compiler/basicTypes/MkId.lhs -3 +5
M ./compiler/coreSyn/CoreUnfold.lhs -2 +84
View patch online:
More information about the Cvs-ghc