[GHC] #15696: Derived Ord instance for enumerations with more than 8 elements seems to be incorrect
GHC
ghc-devs at haskell.org
Tue Oct 2 21:56:32 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: |
-------------------------------------+-------------------------------------
Comment (by dfeuer):
Ah... I am not entirely wrong, but I am partly wrong, because types with
many constructors get tagged 1 when evaluated. I think we should at least
be able to add a rule that recognizes when `dataToTag#` is used with a
type with only a few constructors: see the logic in the `cgAlts gc_plan
bndr (AlgAlt tycon) alts` case in `compiler/codeGen/StgCmmExpr.hs`. That
way we only have to call `getConstrTag` when
1. The type is unknown,
2. The type has too many constructors, or
3. The tag bits are 0.
I imagine you can do this quite easily by copying a bit of the
`splitTyConApp_maybe` logic from `tagToEnumRule` to `dataToTagRule` in
`PrelRules.hs` and adding a `DataToTagUsingTagOp` to supplement
`DataToTagOp`.
--
Ticket URL: <http://ghc.haskell.org/trac/ghc/ticket/15696#comment:26>
GHC <http://www.haskell.org/ghc/>
The Glasgow Haskell Compiler
More information about the ghc-tickets
mailing list