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,273
    • Issues 4,273
    • List
    • Boards
    • Labels
    • Service Desk
    • Milestones
    • Iterations
  • Merge Requests 413
    • Merge Requests 413
  • 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
  • #17623

Closed
Open
Opened Dec 29, 2019 by Ben Gamari@bgamari🐢Maintainer

SpecConstr creates redundant many specialisations?

While looking at #17619 (closed) I noticed that SpecConstr appears to be producing more than one specialisation/rule for each call pattern. Specifically, when looking at output from this trace:

@@ -1738,7 +1738,8 @@ spec_one env fn arg_bndrs body (call_pat@(qvars, pats), rule_number)
               rule       = mkRule this_mod True {- Auto -} True {- Local -}
                                   rule_name inline_act fn_name qvars pats rule_rhs
                            -- See Note [Transfer activation]
-        ; return (spec_usg, OS { os_pat = call_pat, os_rule = rule
+        ; pprTrace "sc-rule" (ppr rule) $
+          return (spec_usg, OS { os_pat = call_pat, os_rule = rule
                                , os_id = spec_id
                                , os_rhs = spec_rhs }) }
 

I noticed three distinct rules emitted of the form (up to alpha renaming):

   1 sc-rule                                                                                                                                                                
7464   "SC:$weerr0" [2]                                                                                                                                                     
   1   ┊ ┊ forall (sc_s3W0 :: Int#)                                                                                                                                         
   2   ┊ ┊ ┊ ┊ ┊ ┊(sc_s3W1 :: Int#)                                                                                                                                         
   3   ┊ ┊ ┊ ┊ ┊ ┊(sc_s3W2 :: Set (ErrorItem (Token [Char])))                                                                                                               
   4   ┊ ┊ ┊ ┊ ┊ ┊(sc_s3W3 :: Set (ErrorItem (Token [Char]))).                                                                                                              
   5   ┊ ┊ ┊ $weerr_Xu (TrivialError                                                                                                                                        
   6   ┊ ┊ ┊ ┊ ┊ ┊ ┊ ┊ ┊ ┊@ [Char]                                                                                                                                          
   7   ┊ ┊ ┊ ┊ ┊ ┊ ┊ ┊ ┊ ┊@ ()                                                                                                                                              
   8   ┊ ┊ ┊ ┊ ┊ ┊ ┊ ┊ ┊ ┊(I# sc_s3W0)                                                                                                                                      
   9   ┊ ┊ ┊ ┊ ┊ ┊ ┊ ┊ ┊ ┊lvl_s2Zq                                                                                                                                          
  10   ┊ ┊ ┊ ┊ ┊ ┊ ┊ ┊ ┊ ┊(Bin                                                                                                                                              
  11   ┊ ┊ ┊ ┊ ┊ ┊ ┊ ┊ ┊ ┊ ┊ @ (ErrorItem (Token [Char])) sc_s3W1 lvl_s3l6 sc_s3W2 sc_s3W3))                                                                                
  12   ┊ ┊ ┊ = jump $s$weerr_s3W9 sc_s3W0 sc_s3W1 sc_s3W2 sc_s3W3     
Assignee
Assign to
None
Milestone
None
Assign milestone
Time tracking
None
Due date
None
Reference: ghc/ghc#17623