#7378: Identical alts/bad divInt# code
-------------------------------------+--------------------------------------
 Reporter:  daniel.is.fischer        |          Owner:                  
     Type:  bug                      |         Status:  new             
 Priority:  normal                   |      Component:  Compiler        
  Version:  7.6.1                    |       Keywords:                  
       Os:  Unknown/Multiple         |   Architecture:  Unknown/Multiple
  Failure:  Runtime performance bug  |       Testcase:                  
Blockedby:                           |       Blocking:                  
  Related:  7360                     |  
-------------------------------------+--------------------------------------
 [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#`.

-- 
Ticket URL: <http://hackage.haskell.org/trac/ghc/ticket/7378>
GHC <http://www.haskell.org/ghc/>
The Glasgow Haskell Compiler

_______________________________________________
Glasgow-haskell-bugs mailing list
Glasgow-haskell-bugs@haskell.org
http://www.haskell.org/mailman/listinfo/glasgow-haskell-bugs

Reply via email to