
#16254: INLINABLE pragma and newtype wrappers prevent inlining -------------------------------------+------------------------------------- Reporter: monoidal | Owner: (none) Type: bug | Status: new Priority: normal | Milestone: Component: Compiler | Version: 8.6.3 Keywords: | Operating System: Unknown/Multiple Architecture: | Type of failure: None/Unknown Unknown/Multiple | Test Case: | Blocked By: Blocking: | Related Tickets: #5327 Differential Rev(s): | Wiki Page: -------------------------------------+------------------------------------- In #5327, we allowed case-of-known constructor to see through bindings that were marked as INLINABLE and used newtypes. However, this works only if the newtype does not have a wrapper. The following code, which is the same as T5237 except for the extra type parameters in Size, does not cause the optimization to fire. {{{ {-# LANGUAGE GADTs, ExplicitForAll #-} module T16254 where newtype Size a b where Size :: forall b a. Int -> Size a b {-# INLINABLE val2 #-} val2 = Size 17 f n = case val2 of Size s -> s + s > n }}} The reason is that `exprIsConApp_maybe` sees `$WSize (I# 17#)`, which is an application with a nontrivial argument. In general, this could cause duplication of work, but in this case we're dealing with a newtype wrapper, so this is safe. -- Ticket URL: http://ghc.haskell.org/trac/ghc/ticket/16254 GHC http://www.haskell.org/ghc/ The Glasgow Haskell Compiler