[GHC] #14644: Improve cmm/assembly for pattern matches with two constants.
GHC
ghc-devs at haskell.org
Fri Jan 26 22:22:47 UTC 2018
#14644: Improve cmm/assembly for pattern matches with two constants.
-------------------------------------+-------------------------------------
Reporter: AndreasK | Owner: AndreasK
Type: task | Status: patch
Priority: normal | Milestone:
Component: Compiler | Version: 8.2.2
(CodeGen) | Keywords: Codegen, CMM,
Resolution: | Patterns, Pattern Matching
Operating System: Unknown/Multiple | Architecture:
| Unknown/Multiple
Type of failure: None/Unknown | Test Case:
Blocked By: | Blocking:
Related Tickets: | Differential Rev(s): Phab:D4294
Wiki Page: |
-------------------------------------+-------------------------------------
Comment (by Ben Gamari <ben@…>):
In [changeset:"7ff6023537fdef32bbe9b4c357012d705d9b931f/ghc" 7ff6023/ghc]:
{{{
#!CommitTicketReference repository="ghc"
revision="7ff6023537fdef32bbe9b4c357012d705d9b931f"
cmm: Use two equality checks for two alt switch with default
For code like:
f 1 = e1
f 7 = e2
f _ = e3
We can treat it as a sparse jump table, check if we are outside of the
range in one direction first and then start checking the values.
GHC currently does this by checking for x>7, then x <= 7 and at last x
== 1.
This patch changes this such that we only compare for equality against
the two values and jump to the default if non are equal.
The resulting code is both faster and smaller.
wheel-sieve1 improves by 4-8% depending on problem size.
This implements the idea from #14644
Reviewers: bgamari, simonmar, simonpj, nomeata
Reviewed By: simonpj, nomeata
Subscribers: nomeata, simonpj, rwbarton, thomie, carter
Differential Revision: https://phabricator.haskell.org/D4294
}}}
--
Ticket URL: <http://ghc.haskell.org/trac/ghc/ticket/14644#comment:15>
GHC <http://www.haskell.org/ghc/>
The Glasgow Haskell Compiler
More information about the ghc-tickets
mailing list