[GHC] #14224: zipWith does not inline

#14224: zipWith does not inline -------------------------------------+------------------------------------- Reporter: dfeuer | Owner: (none) Type: bug | Status: new Priority: normal | Milestone: 8.4.1 Component: Core | Version: 8.2.1 Libraries | Keywords: | 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: -------------------------------------+------------------------------------- `zipWith` is currently defined {{{#!hs zipWith :: (a->b->c) -> [a]->[b]->[c] zipWith _f [] _bs = [] zipWith _f _as [] = [] zipWith f (a:as) (b:bs) = f a b : zipWith f as bs }}} For now (I gather that might change soon?), the fact that it's recursive means that it will never inline. But we really want it to inline when applied to a function, for the same reasons we want `map` to inline. If `f` is something like `const`, `flip const`, or a lazy constructor, it's wasteful to create a thunk to apply it. All three of those cases are common. So unless/until we start inlining recursive functions, we probably want to use {{{#!hs zipWith f = go where go [] _ = [] go _ [] = [] go (x:xs) (y:ys) = f x y : go xs ys }}} There will probably be some regressions, of course. -- Ticket URL: http://ghc.haskell.org/trac/ghc/ticket/14224 GHC http://www.haskell.org/ghc/ The Glasgow Haskell Compiler

#14224: zipWith does not inline -------------------------------------+------------------------------------- Reporter: dfeuer | Owner: (none) Type: bug | Status: new Priority: normal | Milestone: 8.4.1 Component: Core Libraries | Version: 8.2.1 Resolution: | Keywords: 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: | -------------------------------------+------------------------------------- Comment (by nomeata): Loopification in the current planned form does not apply here (zipWith is not tail-recursive), so if that is what you referring to: It won’t help here. The proposed form looks reasonable. -- Ticket URL: http://ghc.haskell.org/trac/ghc/ticket/14224#comment:1 GHC http://www.haskell.org/ghc/ The Glasgow Haskell Compiler

#14224: zipWith does not inline -------------------------------------+------------------------------------- Reporter: dfeuer | Owner: (none) Type: bug | Status: new Priority: normal | Milestone: 8.4.1 Component: Core Libraries | Version: 8.2.1 Resolution: | Keywords: 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: | -------------------------------------+------------------------------------- Comment (by bgamari): I agree, separating out the recursive bit as proposed sounds quite reasonable. Would you care to offer a patch? It would be a good idea to mention this is the changelog of `base` while you are at it. -- Ticket URL: http://ghc.haskell.org/trac/ghc/ticket/14224#comment:2 GHC http://www.haskell.org/ghc/ The Glasgow Haskell Compiler

#14224: zipWith does not inline -------------------------------------+------------------------------------- Reporter: dfeuer | Owner: (none) Type: bug | Status: new Priority: normal | Milestone: 8.4.1 Component: Core Libraries | Version: 8.2.1 Resolution: | Keywords: Operating System: Unknown/Multiple | Architecture: Type of failure: Runtime | Unknown/Multiple performance bug | Test Case: Blocked By: | Blocking: Related Tickets: | Differential Rev(s): Phab:D3986 Wiki Page: | -------------------------------------+------------------------------------- Changes (by sighingnow): * differential: => Phab:D3986 -- Ticket URL: http://ghc.haskell.org/trac/ghc/ticket/14224#comment:3 GHC http://www.haskell.org/ghc/ The Glasgow Haskell Compiler

#14224: zipWith does not inline
-------------------------------------+-------------------------------------
Reporter: dfeuer | Owner: (none)
Type: bug | Status: new
Priority: normal | Milestone: 8.4.1
Component: Core Libraries | Version: 8.2.1
Resolution: | Keywords:
Operating System: Unknown/Multiple | Architecture:
Type of failure: Runtime | Unknown/Multiple
performance bug | Test Case:
Blocked By: | Blocking:
Related Tickets: | Differential Rev(s): Phab:D3986
Wiki Page: |
-------------------------------------+-------------------------------------
Comment (by Ben Gamari

#14224: zipWith does not inline -------------------------------------+------------------------------------- Reporter: dfeuer | Owner: (none) Type: bug | Status: closed Priority: normal | Milestone: 8.4.1 Component: Core Libraries | Version: 8.2.1 Resolution: fixed | Keywords: Operating System: Unknown/Multiple | Architecture: Type of failure: Runtime | Unknown/Multiple performance bug | Test Case: Blocked By: | Blocking: Related Tickets: | Differential Rev(s): Phab:D3986 Wiki Page: | -------------------------------------+------------------------------------- Changes (by bgamari): * status: new => closed * resolution: => fixed Comment: Thanks sighingnow! -- Ticket URL: http://ghc.haskell.org/trac/ghc/ticket/14224#comment:5 GHC http://www.haskell.org/ghc/ The Glasgow Haskell Compiler
participants (1)
-
GHC