[GHC] #13182: Rethinking dataToTag#

#13182: Rethinking dataToTag# -------------------------------------+------------------------------------- Reporter: dfeuer | Owner: Type: task | Status: new Priority: normal | Milestone: 8.2.1 Component: Compiler | Version: 8.1 Keywords: | Operating System: Unknown/Multiple Architecture: | Type of failure: None/Unknown Unknown/Multiple | Test Case: | Blocked By: Blocking: | Related Tickets: Differential Rev(s): | Wiki Page: -------------------------------------+------------------------------------- We currently use a primop `dataToTag#` that requires some careful handling because it can only be applied to something that has already been evaluated. We (now) mark it `can_fail` to prevent it from floating out, and then add a fix-up pass in CorePrep just in case things went wrong. Could we do something simpler? Suppose we had {{{#!hs -- The real primop, preferably not exported from *anywhere*, but at least documented as never to be used outside GHC. secretDataToTag# :: a -> Int# -- A wired-in safe version dataToTag# :: a -> Int# dataToTag# !a = secretDataToTag# a {-# NOINLINE dataToTag# #-} }}} Then `dataToTag#` could be inlined in CorePrep, just like `runRW#`. === Questions === How would this interact with float out? It should be perfectly safe to float out when its argument is known to be forced, but it seems likely we'll run into let/app invariant failures. What RULES do we (or should we) have for `dataToTag#`? How will this change affect them? My vague recollection is that we don't have any, but it would be pretty nice to apply something equivalent to case-of-known- constructor. Whenever `dataToTag#` is applied to a known constructor, we should be able to evaluate it. The earlier we do this the better it will inform simplification. -- Ticket URL: http://ghc.haskell.org/trac/ghc/ticket/13182 GHC http://www.haskell.org/ghc/ The Glasgow Haskell Compiler

#13182: Rethinking dataToTag# -------------------------------------+------------------------------------- Reporter: dfeuer | Owner: Type: task | Status: new Priority: normal | Milestone: 8.2.1 Component: Compiler | Version: 8.1 Resolution: | Keywords: Operating System: Unknown/Multiple | Architecture: | Unknown/Multiple Type of failure: None/Unknown | Test Case: Blocked By: | Blocking: Related Tickets: | Differential Rev(s): Wiki Page: | -------------------------------------+------------------------------------- Comment (by simonpj):
Then dataToTag# could be inlined in CorePrep, just like runRW#.
I think that is precisely equivalent to what happens now, so yes it'd be ok. But then `CorePrep` would need to be able to eliminate the freshly- introduced case if it was redundant: {{{ case x of { DEFAULT -> dataToTag# x } }}} Now if we inline `dataToTag#` we'll get a second case that must be eliminated. The simplifier does this already. To me the status quo looks simpler. -- Ticket URL: http://ghc.haskell.org/trac/ghc/ticket/13182#comment:1 GHC http://www.haskell.org/ghc/ The Glasgow Haskell Compiler

#13182: Rethinking dataToTag# -------------------------------------+------------------------------------- Reporter: dfeuer | Owner: (none) Type: task | Status: new Priority: normal | Milestone: 8.4.1 Component: Compiler | Version: 8.1 Resolution: | Keywords: datacon-tags Operating System: Unknown/Multiple | Architecture: | Unknown/Multiple Type of failure: None/Unknown | Test Case: Blocked By: | Blocking: Related Tickets: | Differential Rev(s): Wiki Page: | -------------------------------------+------------------------------------- Changes (by bgamari): * keywords: => datacon-tags -- Ticket URL: http://ghc.haskell.org/trac/ghc/ticket/13182#comment:3 GHC http://www.haskell.org/ghc/ The Glasgow Haskell Compiler

#13182: Rethinking dataToTag# -------------------------------------+------------------------------------- Reporter: dfeuer | Owner: (none) Type: task | Status: new Priority: low | Milestone: 8.4.1 Component: Compiler | Version: 8.1 Resolution: | Keywords: datacon-tags Operating System: Unknown/Multiple | Architecture: | Unknown/Multiple Type of failure: None/Unknown | Test Case: Blocked By: | Blocking: Related Tickets: | Differential Rev(s): Wiki Page: | -------------------------------------+------------------------------------- Changes (by dfeuer): * priority: normal => low -- Ticket URL: http://ghc.haskell.org/trac/ghc/ticket/13182#comment:4 GHC http://www.haskell.org/ghc/ The Glasgow Haskell Compiler
participants (1)
-
GHC