[GHC] #15019: Fix performance regressions from #14737
GHC
ghc-devs at haskell.org
Wed Apr 25 10:26:35 UTC 2018
#15019: Fix performance regressions from #14737
-------------------------------------+-------------------------------------
Reporter: tdammers | Owner: tdammers
Type: bug | Status: new
Priority: normal | Milestone: 8.6.1
Component: Compiler | Version:
Resolution: | Keywords:
Operating System: Unknown/Multiple | Architecture:
Type of failure: Compile-time | Unknown/Multiple
performance bug | Test Case:
Blocked By: | Blocking:
Related Tickets: #14737 | Differential Rev(s): phab:D4568
Wiki Page: |
-------------------------------------+-------------------------------------
Comment (by tdammers):
OK, sure.
Just check out GHC HEAD, and apply this patch:
{{{
diff --git a/compiler/coreSyn/CoreOpt.hs b/compiler/coreSyn/CoreOpt.hs
index f1ff68d133..6ddab2c94e 100644
--- a/compiler/coreSyn/CoreOpt.hs
+++ b/compiler/coreSyn/CoreOpt.hs
@@ -958,10 +958,14 @@ pushCoTyArg :: CoercionR -> Type -> Maybe (Type,
Maybe CoercionR)
-- If the returned coercion is Nothing, then it would have been
reflexive;
-- it's faster not to compute it, though.
pushCoTyArg co ty
+ | isReflCo co
+ = Just (ty, Nothing)
+
-- The following is inefficient - don't do `eqType` here, the coercion
-- optimizer will take care of it. See Trac #14737.
- -- -- | tyL `eqType` tyR
- -- -- = Just (ty, Nothing)
+ | tyL `eqType` tyR
+ = pprTrace "eqType fired: " (ppr (co, tyL, tyR)) $
+ Just (ty, Nothing)
| isForAllTy tyL
= ASSERT2( isForAllTy tyR, ppr co $$ ppr ty )
@@ -993,10 +997,15 @@ pushCoValArg :: CoercionR -> Maybe (Coercion, Maybe
Coercion)
-- If the second returned Coercion is actually Nothing, then no cast is
necessary;
-- the returned coercion would have been reflexive.
pushCoValArg co
+ -- The "easy" case; this doesn't interest us.
+ | isReflCo co
+ = Just (mkRepReflCo arg, Nothing)
+
-- The following is inefficient - don't do `eqType` here, the coercion
-- optimizer will take care of it. See Trac #14737.
- -- -- | tyL `eqType` tyR
- -- -- = Just (mkRepReflCo arg, Nothing)
+ | tyL `eqType` tyR
+ = pprTrace "eqType fired: " (ppr (co, tyL, tyR)) $
+ Just (mkRepReflCo arg, Nothing)
| isFunTy tyL
, (co1, co2) <- decomposeFunCo Representational co
}}}
Build with the `validate` flavor, and then:
{{{
./inplace/bin/ghc-stage2 -O2 testsuite/tests/perf/compiler/T9020.hs
-fforce-recomp
}}}
--
Ticket URL: <http://ghc.haskell.org/trac/ghc/ticket/15019#comment:8>
GHC <http://www.haskell.org/ghc/>
The Glasgow Haskell Compiler
More information about the ghc-tickets
mailing list