[GHC] #7360: Case-of-identical-alts optimisation fails abjectly
GHC
cvs-ghc at haskell.org
Wed Nov 21 14:30:43 CET 2012
#7360: Case-of-identical-alts optimisation fails abjectly
---------------------------------+------------------------------------------
Reporter: simonpj | Owner:
Type: bug | Status: new
Priority: normal | Milestone:
Component: Compiler | Version: 7.6.1
Keywords: | Os: Unknown/Multiple
Architecture: Unknown/Multiple | Failure: None/Unknown
Difficulty: Unknown | Testcase:
Blockedby: | Blocking:
Related: |
---------------------------------+------------------------------------------
Comment(by simonpj):
I'm afraid I don't but let me try here to explain the issues, and you can
have a go yourself.
To implement my comment above, here are the changes I have in mind:
* Remove the 'scrut' arg to `simplAlt` and `addBinderUnfolding`; simplify
the latter by eliminating the `(Just v)` alternative.
* Remove the call to `(isNothing scrut`) around line 2072 of
`Simplify.lhs`
Then you want to check that things are better. In particular I'd like
to be confident that we have not thereby increased the number of
simplifier iterations, or (worse still) claiming that something is
dead when it isn't.
So it would be good to run a nofib performance test before and after,
with -dcore-lint. That mainly checks runtime performance and
allocation. Adding `-ddump-simpl-stats` and looking for the
`SimplifierDone` figure tells you the number of simplifier iterations,
which should not increase. We don't have an automated way to check that.
Even this isn't ideal. If we have
{{{
case x of y {
[] -> length y
(_:_) -> length y }
}}}
we won't combine the alteratives because `y` is alive in the alternatives.
(See teh (necessary) call to `(isDeadBinder case_bndr')` online 2072 of
`Simplify.lhs`. This is silly.
So the next thing I'd try is moving the `Merge Identical ALternatives`
code from `mkCase1` to `prepareAlts`. The latter happens ''before''
the alternatives are simplified, so it'd be fine to simply combine the
alternatives without messing with the occurrence info on the
alternative binders at all.
Again easy to try, but we'd want the same performance testing as
before. Would you like to try?
Simon
--
Ticket URL: <http://hackage.haskell.org/trac/ghc/ticket/7360#comment:3>
GHC <http://www.haskell.org/ghc/>
The Glasgow Haskell Compiler
More information about the Glasgow-haskell-bugs
mailing list