[GHC] #15696: Derived Ord instance for enumerations with more than 8 elements seems to be incorrect
GHC
ghc-devs at haskell.org
Fri Oct 5 09:04:10 UTC 2018
#15696: Derived Ord instance for enumerations with more than 8 elements seems to be
incorrect
-------------------------------------+-------------------------------------
Reporter: mrkkrp | Owner: (none)
Type: bug | Status: patch
Priority: highest | Milestone: 8.6.2
Component: Compiler | Version: 8.6.1
Resolution: | Keywords:
Operating System: Unknown/Multiple | Architecture:
Type of failure: Incorrect result | Unknown/Multiple
at runtime | Test Case:
Blocked By: | Blocking:
Related Tickets: | Differential Rev(s): Phab:D5196,
Wiki Page: | Phab:D5201
-------------------------------------+-------------------------------------
Comment (by osa1):
Simon, what do you think about marking `dataToTag#` as can't fail? I
thought it
makes sense, but when I do that I get this lint error: (add type
annotation on scrutinee)
{{{
<no location info>: warning:
In the expression: tagToEnum#
@ Bool
(case (ds :: Instr) of lwild {
__DEFAULT -> 0#;
C_ALabel_1 ipv -> 1#
})
This argument does not satisfy the let/app invariant:
case ds of lwild {
__DEFAULT -> 0#;
C_ALabel_1 ipv -> 1#
}
}}}
Note that the expression does not actually have `dataToTag#`. Apparently
making
`dataToTag#` can't fail enables some transformations, which leads to this.
(Type of `ds` is a lifted sum type named `Instr`)
If I don't make it "can't fail", I get this expression instead
{{{
case GHC.Prim.dataToTag# @ Instr ds of b# { __DEFAULT ->
GHC.Prim.tagToEnum#
@ Bool
(case b# of {
__DEFAULT -> 0#;
0# -> 1#
})
};
}}}
The version with "can't fail" is better because we eliminate a redundant
`dataToTag#` call, but apparently the resulting expression is not "OK for
speculation".
I think this expression is not OK for speculation because the scrutinee is
lifted, but I'm not sure. I also don't know why lifted scrutinee is a
problem
for speculation..
--
Ticket URL: <http://ghc.haskell.org/trac/ghc/ticket/15696#comment:49>
GHC <http://www.haskell.org/ghc/>
The Glasgow Haskell Compiler
More information about the ghc-tickets
mailing list