id	summary	reporter	owner	description	type	status	priority	milestone	component	version	resolution	keywords	cc	os	architecture	failure	difficulty	testcase	blockedby	blocking	related
2132	Optimise nested comparisons	simonpj		"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"	bug	new	normal	_|_	Compiler	6.8.2			v.dijk.bas@… hackage.haskell.org@… carter.schonwald@…	Unknown/Multiple	Unknown/Multiple	Runtime performance bug	Unknown				
