[GHC] #13077: Worker/wrapper can break the let-app invariant

#13077: Worker/wrapper can break the let-app invariant
-------------------------------------+-------------------------------------
Reporter: simonpj | Owner:
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:
-------------------------------------+-------------------------------------
Consider this
{{{
{-# LANGUAGE MagicHash #-}
module Bar where
import GHC.Exts
data X = A | B | C
data T = MkT !X Int# Int#
f (MkT x 0# _) = True
f (MkT x n _) = let v = case x of
A -> 1#
B -> 2#
C -> n
in f (MkT x v v)
}}}
Compile with -O and (with GHC 8) you'll get
{{{
*** Core Lint errors : in result of Simplifier ***
Bar.hs:10:23: Warning:
[RHS of v_s1IX :: Int#]
The type of this binder is primitive: v_s1IX
Binder's type: Int#
*** Offending Program ***
Rec {
f [InlPrag=INLINE[0]] :: T -> Bool
[LclIdX,
Arity=1,
Str=DmdType ,
Unf=Unf{Src=InlineStable, TopLvl=True, Value=True, ConLike=True,
WorkFree=True, Expandable=True,
Guidance=ALWAYS_IF(arity=1,unsat_ok=True,boring_ok=False)
Tmpl= \ (w_s1Jq [Occ=Once!] :: T) ->
case w_s1Jq
of _ [Occ=Dead]
{ MkT ww_s1Jt [Occ=Once] ww_s1Ju [Occ=Once] _ [Occ=Dead]
->
$wf_s1Jx ww_s1Jt ww_s1Ju
}}]
f =
\ (w_s1Jq :: T) ->
case w_s1Jq of _ [Occ=Dead] { MkT ww_s1Jt ww_s1Ju ww_s1Jv ->
$wf_s1Jx ww_s1Jt ww_s1Ju
}
$wf_s1Jx [InlPrag=[0], Occ=LoopBreaker] :: X -> Int# -> Bool
[LclId,
Arity=2,
Str=DmdType ,
Unf=Unf{Src=<vanilla>, TopLvl=True, Value=True, ConLike=True,
WorkFree=True, Expandable=True, Guidance=IF_ARGS [40 30] 80 10}]
$wf_s1Jx =
\ (ww_s1Jt :: X) (ww_s1Ju :: Int#) ->
case ww_s1Ju of ds_X1IO [Dmd=] :: Int#
[LclId,
Str=DmdType,
Unf=Unf{Src=<vanilla>, TopLvl=False, Value=False,
ConLike=False,
WorkFree=True, Expandable=True, Guidance=IF_ARGS [] 30
0}]
v_s1IX =
case ww_s1Jt of _ [Occ=Dead, Dmd=

#13077: Worker/wrapper can break the let-app invariant -------------------------------------+------------------------------------- Reporter: simonpj | Owner: 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 simonpj): Here's a related one where we need to record evaluted-ness on CPR result binders {{{ data X = A | B | C data T = MkT !X Int# Int# g :: Int -> T g 0 = MkT A 1# 2# g n = g (n-1) boo :: Int -> T boo k = case g k of MkT x n _ -> let v = case x of A -> 1# B -> 2# C -> n in MkT x v v }}} Here we get a wrapper for `g` like this {{{ g x = case $wg x of (# w1, w2 #) -> MkT w1 w2 w2 }}} It's important to record that `w1` is evaluated, as the use in `boo` makes clear. -- Ticket URL: http://ghc.haskell.org/trac/ghc/ticket/13077#comment:1 GHC http://www.haskell.org/ghc/ The Glasgow Haskell Compiler

#13077: Worker/wrapper can break the let-app invariant
-------------------------------------+-------------------------------------
Reporter: simonpj | Owner:
Type: bug | Status: closed
Priority: normal | Milestone:
Component: Compiler | Version: 8.0.1
Resolution: fixed | Keywords:
Operating System: Unknown/Multiple | Architecture:
| Unknown/Multiple
Type of failure: None/Unknown | Test Case:
| stranal/should_compile/T13077,
| T13077a
Blocked By: | Blocking:
Related Tickets: | Differential Rev(s):
Wiki Page: |
-------------------------------------+-------------------------------------
Changes (by simonpj):
* status: new => closed
* testcase: => stranal/should_compile/T13077, T13077a
* resolution: => fixed
Comment:
Fixed by
{{{
commit 596dece7866006d699969f775fd97bd306aad85b
Author: Simon Peyton Jones
participants (1)
-
GHC