[commit: ghc] ghc-8.0: Defer inlining of Eq for primitive types (ed3398d)
git at git.haskell.org
git at git.haskell.org
Thu Mar 24 22:00:22 UTC 2016
Repository : ssh://git@git.haskell.org/ghc
On branch : ghc-8.0
Link : http://ghc.haskell.org/trac/ghc/changeset/ed3398d176fc777dff8f5ae5315425e40c705c2d/ghc
>---------------------------------------------------------------
commit ed3398d176fc777dff8f5ae5315425e40c705c2d
Author: Ben Gamari <bgamari.foss at gmail.com>
Date: Thu Mar 24 11:24:32 2016 +0100
Defer inlining of Eq for primitive types
Summary:
This is one solution to #11688, wherein (==) was inlined to soon
defeating a rewrite rule provided by bytestring. Since the RHSs of Eq's
methods are simple, there is little to be gained and much to be lost by
inlining them early.
For instance, the bytestring library provides,
```lang=haskell
break :: (Word8 -> Bool) -> ByteString -> (ByteString, ByteString)
breakByte :: Word8 -> ByteString -> (ByteString, ByteString)
```
and a rule
```
forall x. break ((==) x) = breakByte x
```
since `breakByte` implments an optimized version of `break (== x)` for
known `x :: Word8`. If we allow `(==)` to be inlined too early, we will
prevent this rule from firing. This was the cause of #11688.
This patch just defers the `Eq` methods, although it's likely worthwhile
giving `Ord` this same treatment. This regresses compiler allocations
for T9661 by about 8% due to the additional inlining that we now require
the simplifier to perform.
Updates the `bytestring` submodule to include updated rewrite rules
which match on `eqWord8` instead of `(==)`.
Test Plan:
* Validate, examine performance impact
Reviewers: simonpj, hvr, austin
Subscribers: thomie
Differential Revision: https://phabricator.haskell.org/D1980
GHC Trac Issues: #11688
(cherry picked from commit 0bd0c31e833055eb3e86177f70c4b4d93d5a1c11)
>---------------------------------------------------------------
ed3398d176fc777dff8f5ae5315425e40c705c2d
libraries/base/GHC/Char.hs | 9 +++-
libraries/base/GHC/Float.hs | 20 +++++----
libraries/base/GHC/Int.hs | 74 +++++++++++++++++++++++++++----
libraries/base/GHC/Word.hs | 77 +++++++++++++++++++++++++++++---
libraries/ghc-prim/GHC/Classes.hs | 87 +++++++++++++++++++++++++++++++++----
testsuite/tests/perf/compiler/all.T | 5 ++-
6 files changed, 236 insertions(+), 36 deletions(-)
Diff suppressed because of size. To see it, use:
git diff-tree --root --patch-with-stat --no-color --find-copies-harder --ignore-space-at-eol --cc ed3398d176fc777dff8f5ae5315425e40c705c2d
More information about the ghc-commits
mailing list