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,249
    • Issues 4,249
    • List
    • Boards
    • Labels
    • Service Desk
    • Milestones
    • Iterations
  • Merge Requests 391
    • Merge Requests 391
  • 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
  • #12877

Closed
Open
Opened Nov 24, 2016 by Sylvain Henry@hsyl20Developer

Constant propagation with basic unboxed arithmetic instructions

I have a program that generates the following core:

main = case t of t0
   0##     -> ...
   DEFAULT -> case t0 -# 1## of t1
      0##    -> ...
      DEFAUT -> case t1 -# 1## of t2
         0##     -> ...
         DEFAULT -> case t2 -# 1## of _
            0##     -> ...
            DEFAULT -> ...

I think it would be possible to implement constant propagation to get:

main = case t of _
   0## -> ...
   1## -> ...
   2## -> ...
   3## -> ...
   DEFAULT -> ...

If I'm not mistaken, to do that we could replace occurences of:

case t -# k# of _ 
   n0# -> ...
   n1# -> ...
   ...
   DEFAULT -> f

with:

case t of _
   (n0#+k#) -> ... -- (ni#+k#) statically computed
   (n1#+k#) -> ...
   ...
   DEFAULT -> f

Any guidance on how to implement that would be appreciated.

Trac metadata
Trac field Value
Version 8.0.1
Type FeatureRequest
TypeOfFailure OtherFailure
Priority normal
Resolution Unresolved
Component Compiler
Test case
Differential revisions
BlockedBy
Related
Blocking
CC
Operating system
Architecture
Assignee
Assign to
8.2.1
Milestone
8.2.1 (Past due)
Assign milestone
Time tracking
None
Due date
None
Reference: ghc/ghc#12877