[GHC] #11533: Stack check not optimized out even if it could be
#11533: Stack check not optimized out even if it could be -------------------------------------+------------------------------------- Reporter: jscholl | Owner: Type: bug | Status: new Priority: normal | Milestone: Component: Compiler | Version: 7.10.3 (CodeGen) | Keywords: cmm | Operating System: Unknown/Multiple Architecture: | Type of failure: Runtime Unknown/Multiple | performance bug Test Case: | Blocked By: Blocking: | Related Tickets: Differential Rev(s): | Wiki Page: -------------------------------------+------------------------------------- CmmLayoutStack tries to remove a stack check if a function uses no stack space. It knows that Sp < SpLim is always false, but not that Sp >= SpLim is always true. However, the latter can arise when GHC flips the comparison (which it does sometimes). An example would be the worker function generated for {{{go}}}: {{{ countDown :: Int -> Int countDown = go 0 where go acc n | n > 0 = go (acc + 1) (n - 1) | otherwise = acc + n }}} -- Ticket URL: <http://ghc.haskell.org/trac/ghc/ticket/11533> GHC <http://www.haskell.org/ghc/> The Glasgow Haskell Compiler
#11533: Stack check not optimized out even if it could be -------------------------------------+------------------------------------- Reporter: jscholl | Owner: Type: bug | Status: patch Priority: normal | Milestone: Component: Compiler | Version: 7.10.3 (CodeGen) | Resolution: | Keywords: cmm Operating System: Unknown/Multiple | Architecture: Type of failure: Runtime | Unknown/Multiple performance bug | Test Case: Blocked By: | Blocking: Related Tickets: | Differential Rev(s): Phab:D1881 Wiki Page: | -------------------------------------+------------------------------------- Changes (by jscholl): * status: new => patch * differential: => Phab:D1881 -- Ticket URL: <http://ghc.haskell.org/trac/ghc/ticket/11533#comment:1> GHC <http://www.haskell.org/ghc/> The Glasgow Haskell Compiler
#11533: Stack check not optimized out even if it could be -------------------------------------+------------------------------------- Reporter: jscholl | Owner: Type: bug | Status: patch Priority: normal | Milestone: Component: Compiler | Version: 7.10.3 (CodeGen) | Resolution: | Keywords: cmm Operating System: Unknown/Multiple | Architecture: Type of failure: Runtime | Unknown/Multiple performance bug | Test Case: Blocked By: | Blocking: Related Tickets: | Differential Rev(s): Phab:D1881 Wiki Page: | -------------------------------------+------------------------------------- Comment (by Ben Gamari <ben@…>): In [changeset:"4ec61411930495fc109be27993c176fd7aaf486d/ghc" 4ec61411/ghc]: {{{ #!CommitTicketReference repository="ghc" revision="4ec61411930495fc109be27993c176fd7aaf486d" Fix the removal of unnecessary stack checks The module CmmLayoutStack removes stack checks if a function does not use stack space. However, it can only recognize checks of the form Sp < SpLim. However, these checks get sometimes rewritten to Sp >= SpLim (with both branches swapped), so we better recognize these checks too. Test Plan: ./validate Reviewers: austin, bgamari, simonpj Reviewed By: simonpj Subscribers: simonpj, thomie Differential Revision: https://phabricator.haskell.org/D1881 GHC Trac Issues: #11533 }}} -- Ticket URL: <http://ghc.haskell.org/trac/ghc/ticket/11533#comment:2> GHC <http://www.haskell.org/ghc/> The Glasgow Haskell Compiler
#11533: Stack check not optimized out even if it could be -------------------------------------+------------------------------------- Reporter: jscholl | Owner: Type: bug | Status: merge Priority: normal | Milestone: 8.0.1 Component: Compiler | Version: 7.10.3 (CodeGen) | Resolution: | Keywords: cmm Operating System: Unknown/Multiple | Architecture: Type of failure: Runtime | Unknown/Multiple performance bug | Test Case: Blocked By: | Blocking: Related Tickets: | Differential Rev(s): Phab:D1881 Wiki Page: | -------------------------------------+------------------------------------- Changes (by bgamari): * status: patch => merge * milestone: => 8.0.1 -- Ticket URL: <http://ghc.haskell.org/trac/ghc/ticket/11533#comment:3> GHC <http://www.haskell.org/ghc/> The Glasgow Haskell Compiler
#11533: Stack check not optimized out even if it could be -------------------------------------+------------------------------------- Reporter: jscholl | Owner: Type: bug | Status: closed Priority: normal | Milestone: 8.0.1 Component: Compiler | Version: 7.10.3 (CodeGen) | Resolution: fixed | Keywords: cmm Operating System: Unknown/Multiple | Architecture: Type of failure: Runtime | Unknown/Multiple performance bug | Test Case: Blocked By: | Blocking: Related Tickets: | Differential Rev(s): Phab:D1881 Wiki Page: | -------------------------------------+------------------------------------- Changes (by bgamari): * status: merge => closed * resolution: => fixed Comment: Merged in d0b4eade3410a09459c4c101546f58e06f9aebcc -- Ticket URL: <http://ghc.haskell.org/trac/ghc/ticket/11533#comment:4> GHC <http://www.haskell.org/ghc/> The Glasgow Haskell Compiler
#11533: Stack check not optimized out even if it could be -------------------------------------+------------------------------------- Reporter: jscholl | Owner: Type: bug | Status: closed Priority: normal | Milestone: 8.0.1 Component: Compiler | Version: 7.10.3 (CodeGen) | Resolution: fixed | Keywords: cmm Operating System: Unknown/Multiple | Architecture: Type of failure: Runtime | Unknown/Multiple performance bug | Test Case: Blocked By: | Blocking: Related Tickets: | Differential Rev(s): Phab:D1881 Wiki Page: | -------------------------------------+------------------------------------- Comment (by thomie): For the record, [https://perf.haskell.org/ghc/#revision/4ec61411930495fc109be27993c176fd7aaf4... perf.haskell.org] reports: {{{ nofib/time/fannkuch-redux 2.727 + 4.66% 2.854 seconds }}} On Phab, Jonas said: "I think nofib contained maybe between 20 and 40 cases where the the stack check was incorrectly not dropped. I could not measure a performance difference, but binary size decreased by a few bytes (as one would expect)" `fannkuch-redux` has been investigated for performance regressions before: #7367, #10457, #10677, #10844, https://phabricator.haskell.org/rGHCb949c96b4960. -- Ticket URL: <http://ghc.haskell.org/trac/ghc/ticket/11533#comment:5> GHC <http://www.haskell.org/ghc/> The Glasgow Haskell Compiler
participants (1)
-
GHC