• plind44@gmail.com's avatar
    MIPS: Consistenly handle power-of-2 divisors in division-like operations. · eb909400
    plind44@gmail.com authored
    Port r19715 (0d6d244)
    
    Original commit message:
    Lithium currently supports 3 division-like operations on integral
    operands: "Normal" division (rounding towards zero), flooring division
    (rounding towards -Infinity) and modulus calculation (the counterpart
    for the "normal" division). For divisors which are a power of 2, one can
    efficiently use some bit fiddling to avoid the actual division for such
    operations. This CL cleanly splits off these operations into separate
    Lithium instructions, making the code much more maintainable and more
    consistent across platforms.
    
    There are 2 basic variations of these bit fiddling algorithms: One
    involving branches and a seemingly more clever one without branches.
    Choosing between the two is not as easy as it seems: Benchmarks (and
    probably real-world) programs seem to favor positive dividends,
    registers and shifting units are sometimes scarce resources, and branch
    prediction is quite good in modern processors. Therefore only the
    "normal" division by a power of 2 is implemented in a branch-free
    manner, this seems to be the best approach in practice. If this turns
    out to be wrong, we can easily and locally change this.
    
    BUG=
    R=plind44@gmail.com
    
    Review URL: https://codereview.chromium.org/189433008
    
    Patch from Balazs Kilvady <kilvadyb@homejinni.com>.
    
    git-svn-id: http://v8.googlecode.com/svn/branches/bleeding_edge@19733 ce2b1a6d-e550-0410-aec6-3dcde31c8c00
    eb909400
lithium-mips.cc 81.1 KB