id	summary	reporter	owner	description	type	status	priority	milestone	component	version	resolution	keywords	cc	os	architecture	failure	difficulty	testcase	blockedby	blocking	related
7378	Identical alts/bad divInt# code	daniel.is.fischer		"[http://stackoverflow.com/questions/13139875/removing-case-with-duplicate-branches-from-haskells-core This] may be the same as #7360, but it may also be a problem in the code generation for `divInt#`. I've reduced it to the following minimal test case:

When compiling

{{{
fun :: Int -> Int
fun i = i `div` 2
}}}

with `ghc -O2 -funfolding-use-threshold=150`, the generated core becomes

{{{
Div2.fun =
  \ (i_aeH :: GHC.Types.Int) ->
    case i_aeH of _ { GHC.Types.I# ww_aiV ->
    case GHC.Prim.># ww_aiV 0 of _ {
      GHC.Types.False ->
        case GHC.Prim.<# ww_aiV 0 of _ {
          GHC.Types.False -> GHC.Types.I# (GHC.Prim.quotInt# ww_aiV 2);
          GHC.Types.True ->
            GHC.Types.I#
              (GHC.Prim.-# (GHC.Prim.quotInt# (GHC.Prim.+# ww_aiV 1) 2) 1)
        };
      GHC.Types.True ->
        case GHC.Prim.<# ww_aiV 0 of _ {
          GHC.Types.False -> GHC.Types.I# (GHC.Prim.quotInt# ww_aiV 2);
          GHC.Types.True ->
            GHC.Types.I#
              (GHC.Prim.-# (GHC.Prim.quotInt# (GHC.Prim.+# ww_aiV 1) 2) 1)
        }
    }
    }
}}}

with two identical `case` alternatives, and in the `True` case, the next comparison is guaranteed to return `False`.

The generated core is good if the divisor is negative, though, so that speaks for taking a look at `divInt#`."	bug	new	normal	7.8.1	Compiler	7.6.1			pho@… hackage.haskell.org@…	Unknown/Multiple	Unknown/Multiple	Runtime performance bug	Unknown				7360
