Better treatment for dataToTag
In libraries/Cabal/Cabal/Distribution/System.hs
I found
eqOS :: OS -> OS -> Bool
eqOS (OtherOS s1) (OtherOS s2) = s1 == (s2 :: String)
eqOs a b = dataToTag a == dataTag b
(actually it's not called eqOS
; it's the derived equality for OS
).
By the time this gets to Core it looks something like this
eqOS a b
= case a of
OtherOS s1 -> case b of
OtherOS s2 -> eqString s1 s2
_ -> case dataToTag b of
16# -> True
r -> False
_ -> dataToTag a == dataToTag b
The dataToTag
code has been duplicated; and in the OtherOS s1
branch GHC can constant-fold the dataToTag
on a
to 16#
, the tag of OtherOS
. But GHC is no so clever for the dataToTag b
. We know that b
is not OtherOS
, so we know its tag is not 16#
, so the innermost case is entirely redundant. But we don't spot that.
Trac metadata
Trac field | Value |
---|---|
Version | 8.2.1 |
Type | Bug |
TypeOfFailure | OtherFailure |
Priority | normal |
Resolution | Unresolved |
Component | Compiler |
Test case | |
Differential revisions | |
BlockedBy | |
Related | |
Blocking | |
CC | |
Operating system | |
Architecture |