#2132: Optimise nested comparisons
-----------------------------------------+----------------------------------
Reporter: simonpj | Owner:
Type: run-time performance bug | Status: new
Priority: normal | Milestone:
Component: Compiler | Version: 6.8.2
Severity: normal | Keywords:
Difficulty: Unknown | Testcase:
Architecture: Unknown | Os: Unknown
-----------------------------------------+----------------------------------
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
--
Ticket URL: <http://hackage.haskell.org/trac/ghc/ticket/2132>
GHC <http://www.haskell.org/ghc/>
The Glasgow Haskell Compiler_______________________________________________
Glasgow-haskell-bugs mailing list
[email protected]
http://www.haskell.org/mailman/listinfo/glasgow-haskell-bugs