
#13429: Optimizer produces Core with an infinite <<loop>> -------------------------------------+------------------------------------- Reporter: lehins | Owner: (none) Type: bug | Status: new Priority: high | Milestone: 7.10.4 Component: Compiler | Version: 8.0.2 Resolution: | Keywords: Operating System: Unknown/Multiple | Architecture: | Unknown/Multiple Type of failure: Runtime crash | Test Case: Blocked By: | Blocking: Related Tickets: | Differential Rev(s): Wiki Page: | -------------------------------------+------------------------------------- Comment (by dfeuer): I've reduced it once more. I believe the fundamental problem here happens in specialization. We get {{{ Rec { -- RHS size: {terms: 2, types: 1, coercions: 0, joins: 0/0} $dArray_s1RC :: Array X Word8 [LclId] $dArray_s1RC = Loop.$fArrayXe @ Word8 GHC.Word.$fNumWord8 -- RHS size: {terms: 2, types: 1, coercions: 0, joins: 0/0} $dArray1_s1RG [Occ=OnceL] :: Array X Word8 [LclId] $dArray1_s1RG = Loop.$fArrayXe @ Word8 $dNum_s1RH -- RHS size: {terms: 2, types: 2, coercions: 0, joins: 0/0} $dNum_s1RH :: Num Word8 [LclId] $dNum_s1RH = Loop.$p1Array @ X @ Word8 $dArray_s1RC -- RHS size: {terms: 7, types: 5, coercions: 0, joins: 0/0} $s$fArrayXe_s1RS [InlPrag=CONLIKE] :: Array X Word8 [LclId, Unf=DFun: \ -> Loop.C:Array TYPE: X TYPE: Word8 Loop.$fArrayXe_$cp1Array @ Word8 $dNum_s1RH Loop.$fArrayXe_$cpromote @ Word8 $dNum_s1RH Loop.$fArrayXe_$cmakeImage @ Word8 $dNum_s1RH] $s$fArrayXe_s1RS = Loop.C:Array @ X @ Word8 (Loop.$fArrayXe_$cp1Array @ Word8 $dNum_s1RH) (Loop.$fArrayXe_$cpromote @ Word8 $dNum_s1RH) (Loop.$fArrayXe_$cmakeImage @ Word8 $dNum_s1RH) ... }}} which doesn't seem ''inherently'' bad (although it's not very clean), but then we also get this rather awful specialization rule: {{{ "SPEC/Main $fArrayXe @ Word8" forall (v_s1RJ :: Num Word8). Loop.$fArrayXe @ Word8 v_s1RJ = $s$fArrayXe_s1RS }}} If this rule fires in the RHS of `$dArray_s1RC`, then we get {{{ $dArray_s1RC = $s$fArrayXe_s1RS }}} Inlining that into `$dNum_s1RH` gives {{{ $dNum_s1RH = Loop.$p1Array @ X @ Word8 $s$fArrayXe_s1RS }}} But `$dNum_s1RH` is used in the definition of `$s$fArrayXe_s1RS`, so we have a loop. I don't know if I've told exactly the right story here, but I think the real story is probably pretty similar. The results will be excruciatingly fragile, depending on whether the right or wrong specialization rule fires. -- Ticket URL: http://ghc.haskell.org/trac/ghc/ticket/13429#comment:14 GHC http://www.haskell.org/ghc/ The Glasgow Haskell Compiler