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 374
    • Merge Requests 374
  • 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
  • #19166

Closed
Open
Opened Jan 04, 2021 by Sylvain Henry@hsyl20Developer

Optimization for binary masks

Motivation

GHC doesn't optimize binary masks as in this example:

foo :: Int -> Int
foo x = case x .&. 0x3 of
    0 -> 0
    1 -> 1
    2 -> 2
    3 -> 3
    4 -> 4 -- unreachable branch but not removed
    _ -> undefined -- required for the PM checker but unreachable too

Proposal

  1. In Core: detect ranges in these cases and remove unreachable branches. To fix this example, we should just have to enhance GHC.Core.Opt.ConstantFold.caseRules to detect (potentially nested) applications of and primops with a constant.
  2. Fix Pattern-Match checker to not require a DEFAULT alternative and to not insert a patError if it is missing.
Assignee
Assign to
None
Milestone
None
Assign milestone
Time tracking
None
Due date
None
Reference: ghc/ghc#19166