No need to enter a scrutinised value
While analysing the output of #13861 I stumbled over an unnecessary pessimisation in handling of scrutinised values. With words of Simon (from https://phabricator.haskell.org/D4267 with minor edits added):
Interesting. Yes, please make a ticket! (And transfer the info below into it.)
I think the issue is this. Given (the STG-ish code)
data Colour = Red | Green | Blue
f x = case x of y
Red -> Green
DEFAULT -> y
(here y
is the case binder) we can just return x
rather than entering it in DEFAULT branch, because y
will be fully evaluated and its pointer will be correctly tagged.
You absolutely can't check for an OccName
of "wild"
!! That is neither necessary nor sufficient :-).
Instead, check isEvaldUnfolding (idUnfolding y)
. See Note [Preserve evaluatedness]
in CoreTidy.hs
. And be sure to augment that note if you make the change.
I would expect perf benefits to be small on average, but it's simple to implement.
Trac metadata
Trac field | Value |
---|---|
Version | 8.2.2 |
Type | Bug |
TypeOfFailure | OtherFailure |
Priority | normal |
Resolution | Unresolved |
Component | Compiler |
Test case | |
Differential revisions | |
BlockedBy | |
Related | #13861 |
Blocking | |
CC | |
Operating system | |
Architecture |