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,242
    • Issues 4,242
    • List
    • Boards
    • Labels
    • Service Desk
    • Milestones
    • Iterations
  • Merge Requests 387
    • Merge Requests 387
  • Requirements
    • Requirements
    • List
  • CI / CD
    • CI / CD
    • Pipelines
    • Jobs
    • Schedules
  • Security & Compliance
    • Security & Compliance
    • Dependency List
    • License Compliance
  • Operations
    • Operations
    • Incidents
    • Environments
  • Analytics
    • Analytics
    • CI / CD
    • Code Review
    • Insights
    • Issue
    • Repository
    • Value Stream
  • Wiki
    • Wiki
  • Snippets
    • Snippets
  • Members
    • Members
  • Collapse sidebar
  • Activity
  • Graph
  • Create a new issue
  • Jobs
  • Commits
  • Issue Boards
  • Glasgow Haskell Compiler
  • GHCGHC
  • Issues
  • #18983

Closed
Open
Opened Nov 24, 2020 by Sebastian Graf@sgraf812Developer

WorkWrap should eliminate unlifted absent coercions

From #18982 (closed):

{-# LANGUAGE GADTs #-}

module Lib where

data GADT a where
  GADT :: Int -> GADT Int

h :: GADT a -> Int
h (GADT n) = n
{-# NOINLINE h #-}

produces

Lib.$wh [InlPrag=NOINLINE]
  :: forall a. (a GHC.Prim.~# Int) -> GHC.Prim.Int# -> GHC.Prim.Int#
Lib.$wh
  = \ (@ a_sxO)
      (ww_sxS [Dmd=<L,A>] :: a_sxO GHC.Prim.~# Int)
      (ww1_sxW :: GHC.Prim.Int#) ->
      ww1_sxW

-- RHS size: {terms: 14, types: 18, coercions: 1, joins: 0/0}
h [InlPrag=NOUSERINLINE[0]] :: forall a. GADT a -> Int
h = \ (@ a_sxO) (w_sxP :: GADT a_sxO) ->
      case w_sxP of { GADT ww1_sxS [Dmd=<L,A>] ww2_sxT ->
      case ww2_sxT of { GHC.Types.I# ww4_sxW ->
      case Lib.$wh @ a_sxO @~ (ww1_sxS :: a_sxO GHC.Prim.~# Int) ww4_sxW
      of ww5_sy1
      { __DEFAULT ->
      GHC.Types.I# ww5_sy1
      }
      }
      }

The coercion argument to the worker $wh is absent, but still present in the simplified code. It would be good if we can change that, as it also makes the type argument @a dead. Then we end up with a much simpler worker and call site.

Not that it would impact runtime performance other than maybe through inlining decisions.

I think the problem has to do with "what kind of absent dummy should we pick for the coercion type?".

Edited Dec 03, 2020 by Sebastian Graf
Assignee
Assign to
None
Milestone
None
Assign milestone
Time tracking
None
Due date
None
Reference: ghc/ghc#18983