Skip to content

GitLab

  • Projects
  • Groups
  • Snippets
  • Help
    • Loading...
  • Help
    • Help
    • Support
    • Community forum
    • Submit feedback
  • Sign in / Register
GHC
GHC
  • Project overview
    • Project overview
    • Details
    • Activity
    • Releases
  • Repository
    • Repository
    • Files
    • Commits
    • Branches
    • Tags
    • Contributors
    • Graph
    • Compare
    • Locked Files
  • Issues 4,389
    • Issues 4,389
    • List
    • Boards
    • Labels
    • Service Desk
    • Milestones
    • Iterations
  • Merge Requests 374
    • Merge Requests 374
  • Requirements
    • Requirements
    • List
  • CI / CD
    • CI / CD
    • Pipelines
    • Jobs
    • Schedules
    • Test Cases
  • Operations
    • Operations
    • Incidents
    • Environments
  • Analytics
    • Analytics
    • CI / CD
    • Code Review
    • Insights
    • Issue
    • Repository
    • Value Stream
  • Wiki
    • Wiki
  • Snippets
    • Snippets
  • Members
    • Members
  • Activity
  • Graph
  • Create a new issue
  • Jobs
  • Commits
  • Issue Boards
Collapse sidebar
  • Glasgow Haskell Compiler
  • GHCGHC
  • Issues
  • #14737

Closed
Open
Opened Jan 30, 2018 by Tobias Dammers@tdammers🦈Developer

Improve performance of Simplify.simplCast

Splitting off task 3 from #11735. When compiling https://ghc.haskell.org/trac/ghc/attachment/ticket/14683/Grammar.hs, simplCast eats up more execution time than we think it should.

From https://ghc.haskell.org/trac/ghc/ticket/11735#comment:10:

Something is clearly wrong with Simplify.simplCast. I think I know what it is. Given

(fun |> co) @t1 @t2 ... @tn

we will call pushCoTyArg n times, and hence does n singleton substitutions, via the n calls to piResultTy.

Solution: gather up those type arguments (easy) and define

pushCoTyArgs :: Coercion -> [Type] -> Maybe ([Type], Coercion)

And https://ghc.haskell.org/trac/ghc/ticket/11735#comment:41:

OK. I looked at pushCoTyArg and friends, and I have a very simple solution: just move the isReflexiveCo case in addCoerce (a local function within Simplify.simplCast) to the top. That should do it. Then pushCoTyArg is never called with a reflexive coercion, and so the piResultTy case won't happen.

Now, pushCoArgs might still call pushCoTyArg with a reflexive coercion, but it can be taught not to as well: Have pushCoArgs return a Maybe ([CoreArg], Maybe Coercion) and pushCoArg return a Maybe (CoreArg, Maybe Coercion). If the second return values are Nothing, that means that there is no cast (i.e., that the cast would have been reflexive). The only client of pushCoArg(s) is exprIsConApp_maybe, which simply omits a cast if pushCoArgs returns Nothing. Then, we never have to bother creating the reflexive coercions.

This should be an easy win all around.

Trac metadata
Trac field Value
Version 8.2.2
Type Bug
TypeOfFailure OtherFailure
Priority normal
Resolution Unresolved
Component Compiler
Test case
Differential revisions
BlockedBy
Related
Blocking
CC goldfire, simonpj, tdammers
Operating system
Architecture
Assignee
Assign to
8.6.1
Milestone
8.6.1 (Past due)
Assign milestone
Time tracking
None
Due date
None
Reference: ghc/ghc#14737