[GHC] #13798: Invalid transformation in simplOptExpr

#13798: Invalid transformation in simplOptExpr -------------------------------------+------------------------------------- Reporter: simonpj | Owner: (none) Type: bug | Status: new Priority: normal | Milestone: Component: Compiler | Version: 8.0.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: -------------------------------------+------------------------------------- Prior to [https://git.haskell.org/ghc.git/commitdiff/1722fa106e10e63160bb2322e2ccb830f... this commit], `CoreOpt.simple_opt_expr` transforms {{{ case e of (b :: t1 ~# t2) DEFAULT -> rhs ==> rhs }}} That was plain wrong when `e` diverges, or calls `error`. Hence the commit. But the commit does this {{{ case Coercible_sc e of (b :: t1 ~# t2) DEFAULT -> rhs ==> rhs }}} narrowing the scope of the transformation to when the scrutinee is application of the Coercible superclass selector {{{ Coercible_sc :: Coercible a b -> (a ~R# b) }}} Here's the code from `CoreOpt`: {{{ | isDeadBinder b , [(DEFAULT, _, rhs)] <- as , isCoercionType (varType b) , (Var fun, _args) <- collectArgs e , fun `hasKey` coercibleSCSelIdKey -- without this last check, we get #11230 = go rhs }}} But that's bizarrely ad-hoc. And, worse, it is flat-out wrong... what if `e` diverges? It's not actually hurting anyone right now, but what we should really do is use `exprOkForSpeculation`; and teach `exprOkForSpeculation` how to deal with class-op selectors. -- Ticket URL: http://ghc.haskell.org/trac/ghc/ticket/13798 GHC http://www.haskell.org/ghc/ The Glasgow Haskell Compiler

#13798: Invalid transformation in simplOptExpr -------------------------------------+------------------------------------- Reporter: simonpj | Owner: (none) Type: bug | Status: new Priority: normal | Milestone: Component: Compiler | Version: 8.0.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 goldfire): A related question, while your attention is on this code, is why the case- of-known-constructor optimization immediately above this code doesn't detect the `Coercible_sc` selector applied to `MkCoercible`. -- Ticket URL: http://ghc.haskell.org/trac/ghc/ticket/13798#comment:1 GHC http://www.haskell.org/ghc/ The Glasgow Haskell Compiler
participants (1)
-
GHC