Skip to content
GitLab
Projects Groups Snippets
  • /
  • Help
    • Help
    • Support
    • Community forum
    • Submit feedback
  • Sign in / Register
  • GHC GHC
  • Project information
    • Project information
    • Activity
    • Labels
    • Members
  • Repository
    • Repository
    • Files
    • Commits
    • Branches
    • Tags
    • Contributors
    • Graph
    • Compare
    • Locked Files
  • Issues 5,347
    • Issues 5,347
    • List
    • Boards
    • Service Desk
    • Milestones
    • Iterations
  • Merge requests 574
    • Merge requests 574
  • CI/CD
    • CI/CD
    • Pipelines
    • Jobs
    • Schedules
    • Test Cases
  • Deployments
    • Deployments
    • Releases
  • Analytics
    • Analytics
    • Value stream
    • CI/CD
    • Code review
    • Insights
    • Issue
    • Repository
  • Wiki
    • Wiki
  • Snippets
    • Snippets
  • Activity
  • Graph
  • Create a new issue
  • Jobs
  • Commits
  • Issue Boards
Collapse sidebar
  • Glasgow Haskell CompilerGlasgow Haskell Compiler
  • GHCGHC
  • Issues
  • #12877
Closed
Open
Issue created 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
To upload designs, you'll need to enable LFS and have an admin enable hashed storage. More information
Assignee
Assign to
Time tracking