i.e. where the second argument is a boxed version of the first. GHC should remove the dead parameter from the join point, to avoid unnecessary boxing.
I get this Core with 7.0.3 and with 7.1.20110629.
I've attached a self-contained example, as small as I can make it. (Making it smaller lets GHC do more unfolding and the problem disappears.) These join points occur inside the 'Deep' case of '$wsplitTree'.
Trac metadata
Trac field
Value
Version
7.0.3
Type
Bug
TypeOfFailure
OtherFailure
Priority
normal
Resolution
Unresolved
Component
Compiler
Test case
Differential revisions
BlockedBy
Related
Blocking
CC
Operating system
Architecture
To upload designs, you'll need to enable LFS and have an admin enable hashed storage. More information
Child items
...
Show closed items
Linked items
0
Link issues together to show that they're related or that one is blocking others.
Learn more.
I've just tried this, and can't reproduce it. I used
ghc-7.0.3 -c -O2 -ddump-simpl T5302.hs
Can you try that and check what's happening?
But yes, I can just about see how this might happen. It would be dealt with by the fix we're investigating for #4941, namely running the strictness analyser a second time near the end.
I can't reproduce either. I must have uploaded the wrong version of the file by mistake -- sorry.
The new file I just uploaded (T5302.hs) should work. With exactly the command you gave, look for the first join point inside the Deep case of wsplitTree. I get
As it can be somewhat subtle exactly when the unused argument arises (in particular, removing too much code causes the unused argument to disappear), I also attached a "less minimal" example. So the file T5302_full.hs is a less cut-down version of the T5302.hs, in case that is helpful. Run
ghc-7.0.3 -c -ddump-simpl -O2 T5302_full.hs
and as before, look for the first join point inside the Deep case of $wsplitTree.
As of 321941a8, this test case (at less the _full.hs one) still generates the unused arguments. In fact, the join point under discussion also contains a join point with the same flaw. This happens with and without a SpecConstr.
In both cases, a late demand analysis removes both unnecessary arguments.
The reason the late demand-analysis doesn't catch it is because we don't do w/w. (Reason: see Note [Final Demand Analyser run] in DmdAnal.)
The absent argument is actually a case binder, passed as a result of Note [Case binders and join points] in Simplify. But in this case it turns out that not only is the case-binder argument eventually unused, but (even worse) every juump to that join point looks like jump j x (I# x). So we box it, and then immediately discard it. Urk.
Just recording breadcrumbs for now. My thought: never pass the case binder to a join point; instead re-box it. It's much the same trade-off as in other places where we worry about re-boxing. And it would be a lot simpler; in particular, we can stop having unfoldings in lambda-binders, which is pretty dodgy anyway.
These tasks won't happen for 8.4 and have been sitting at low priority for quite some time. Consequently I am un-milestoning them. Don't let this stop you, the interested reader, from picking one up, however.
I can confirm @osa1 findings from #5302 (comment 149055). What's the way forward for this ticket? Wasn't there a discussion whether -flate-dmd-anal could be included in -O2?
EDIT: Here's a version of the reproducer updated for compatibility with the Semigroup-Monoid-Proposal (GHC >= 8.0): T5302.hs
Wasn't there a discussion whether -flate-dmd-anal could be included in -O2
I think that idea seems plausible, and almost certainly a modest win (which is what we expect from -O2). It needs someone to try it out run all our benchmarks with and without this change. Pretty simple to do.
It seems this is a duplicate of #4941. One fix discussed above is to pass -flate-dmd-anal, but that is blocked on #6087. Closing this issue in favor of #4941.