#5539: GHC panic - Simplifier ticks exhausted ---------------------------------+------------------------------------------ Reporter: hvr | Owner: simonpj Type: bug | Status: new Priority: high | Milestone: 7.4.1 Component: Compiler | Version: 7.3 Resolution: | Keywords: Os: Linux | Architecture: x86_64 (amd64) Failure: Compile-time crash | Difficulty: Unknown Testcase: | Blockedby: Blocking: | Related: ---------------------------------+------------------------------------------
Comment(by rl): I completely agree about having simple rules. However, the rule about what gets inlined into unfoldings is, IMO, not simple as this example shows. I've argued before that if a function becomes small enough to inline in ''any'' phase (rather than just at the very end) GHC should just freeze its unfolding and mark it as INLINABLE in that phase. This is essentially what happens now within a single module but not across modules. Then, small functions like `not` or `(||)` would always be INLINABLE. GHC would be able to inline them into unfoldings (I'm not sure if it would do so now but there doesn't seem to be a reason not to). This would also remove the (often rather surprising) difference in inlining behaviour depending on whether things are defined in the same module or in different ones. Alternatively, we should go through the standard libraries and mark small functions such as `not` as INLINE or INLINABLE. I agree that GHC allows us to say what we want but the libraries often don't do so. Do we want `not` to be inlined into unfoldings? Most probably, as this example shows. But then we should say so! I will fix `vector`, the change has to be made in the upstream repo, not in GHC's local version. I can't make the bounds check out-of-line because that absolutely kills optimisations and would make the cost of bounds checking far too high. Just as an example, here is a small function: {{{ f :: Vector Int -> Int f xs = (xs ! 0) + (xs ! 1) }}} Here is what GHC generates for this now: {{{ $wf :: Vector Int -> Int# $wf = \xs -> case xs `cast` ... of { Vector a b c -> case 0 #< b of { False -> <error> True -> case 1 #< b of { False -> <error> True -> indexIntArray# c a +# indexIntArray# c (a +# 1) } } } }}} Here is what it would generate if `(!)` wasn't inlined: {{{ $wf = \xs -> case xs ! 0 of { I# x -> case ys ! 1 of { I# y -> x +# y } } }}} That would be really bad. It might be possible to improve this but at the cost of significant increase in vector's code complexity which I'd rather avoid. -- Ticket URL: <http://hackage.haskell.org/trac/ghc/ticket/5539#comment:32> GHC <http://www.haskell.org/ghc/> The Glasgow Haskell Compiler _______________________________________________ Glasgow-haskell-bugs mailing list Glasgow-haskell-bugs@haskell.org http://www.haskell.org/mailman/listinfo/glasgow-haskell-bugs