#5598: Function quotRem is inefficient
---------------------------------+------------------------------------------
    Reporter:  boris             |       Owner:                               
        Type:  task              |      Status:  new                          
    Priority:  normal            |   Component:  Compiler                     
     Version:  7.0.3             |    Keywords:  division, performance, primop
    Testcase:                    |   Blockedby:                               
          Os:  Unknown/Multiple  |    Blocking:                               
Architecture:  x86               |     Failure:  Runtime performance bug      
---------------------------------+------------------------------------------

Comment(by boris):

 Correction: two divs exist only for NCG. LLVM optimiser replaces div by
 smarter code based on shifts, but this code is still duplicated for quot
 and rem.

 Division is duplicated because in the LLVM assembly the dividend is loaded
 twice and optimiser fails to merge divisions.

 {{{
 134         %ln1ot = load i64* %ls1ln
 135         %ln1ou = srem i64 %ln1ot, 123
 136         store i64 %ln1ou, i64* %ls1lW
 137         %ln1ov = load i64* %ls1ln
 138         %ln1ow = sdiv i64 %ln1ov, 123
 }}}

 When I replaced %ln1ov with %ln1ot, the native assembly code performed
 division only once.

-- 
Ticket URL: <http://hackage.haskell.org/trac/ghc/ticket/5598#comment:1>
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

Reply via email to