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,393
    • Issues 4,393
    • List
    • Boards
    • Labels
    • Service Desk
    • Milestones
    • Iterations
  • Merge Requests 378
    • Merge Requests 378
  • 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
  • #12982

Closed
Open
Opened Dec 15, 2016 by erikd@trac-erikd

Missed constant folding oportunities

A work colleague of mine found that some expressions were not being constant folded as expected.

For example:

module Test where
import Data.Int
number :: Int64
number = 2 ^ 10 - 3

compiled using:

ghc -O2 -keep-s-file -c test.hs

should result in an assembler file containing the constant 1021 but doesn't. However, if I change the above expression to:

number = 1024 -3

then the output assembler files does contain the value 1021.

I did a bit of a search and found some constant folding code in the hoopl library, but that doesn't seem to be what GHC actually uses.

Edited Mar 10, 2019 by Simon Peyton Jones
Assignee
Assign to
8.6.1
Milestone
8.6.1 (Past due)
Assign milestone
Time tracking
None
Due date
None
Reference: ghc/ghc#12982