Skip to content

GitLab

  • Menu
Projects Groups Snippets
    • Loading...
  • 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 4,832
    • Issues 4,832
    • List
    • Boards
    • Service Desk
    • Milestones
    • Iterations
  • Merge requests 450
    • Merge requests 450
  • CI/CD
    • CI/CD
    • Pipelines
    • Jobs
    • Schedules
    • Test Cases
  • Deployments
    • Deployments
    • Releases
  • Analytics
    • Analytics
    • CI/CD
    • Code review
    • Insights
    • Issue
    • Repository
    • Value stream
  • Wiki
    • Wiki
  • Snippets
    • Snippets
  • Activity
  • Graph
  • Create a new issue
  • Jobs
  • Commits
  • Issue Boards
Collapse sidebar
  • Glasgow Haskell Compiler
  • GHCGHC
  • Issues
  • #2132

Closed
Open
Created Feb 28, 2008 by Simon Peyton Jones@simonpjDeveloper

Optimise nested comparisons

GHC isn't capable of this optimisation:

  case (x ># y) of             ==>    case (x ># y) of
    True -> ...(x ==# y)...               True -> ...False...
    False -> ...                          False -> ...

That is, knowing that (x>y) we know that the two are not equal.

Also, consider this:

  case (x ># y) of               ==>   case (x >=# y) of
     True -> e                           True -> e
     False -> case (x ==# y) of          False -> e'
                True -> e
                False -> e'

Again this needs special knowlege about comparison operators. However, it does arise. Consider this:

  data T = MkT Int deriving( Eq, Ord )

The derived (>) operation looks like this:

Foo.$dm> =
  \ (eta_a8q :: Foo.T) (eta1_a8r :: Foo.T) ->
    case eta_a8q of wild_B1 { Foo.MkT a1_a60 ->
    case eta1_a8r of wild1_XO { Foo.MkT b1_a62 ->
    case a1_a60 of wild2_a9I { GHC.Base.I# x#_a9K ->
    case b1_a62 of wild11_a9M { GHC.Base.I# y#_a9O ->
    case GHC.Prim.<# x#_a9K y#_a9O of wild3_a9W {
      GHC.Base.False ->
        case GHC.Prim.==# x#_a9K y#_a9O of wild12_a9Z {
          GHC.Base.False -> GHC.Base.True; GHC.Base.True -> GHC.Base.False
        };
      GHC.Base.True -> GHC.Base.False

See also #2130 (closed)

Trac metadata
Trac field Value
Version 6.8.2
Type Bug
TypeOfFailure OtherFailure
Priority normal
Resolution Unresolved
Component Compiler
Test case
Differential revisions
BlockedBy
Related
Blocking
CC
Operating system Unknown
Architecture Unknown
To upload designs, you'll need to enable LFS and have an admin enable hashed storage. More information
Assignee
Assign to
Time tracking