Uploaded image for project: 'JDK'
  1. JDK
  2. JDK-8319526

Re-examine integer modulo operations by constant divisor

XMLWordPrintable

      C2 uses a variant of Granlund & Montgomery's algorithm (as described in Hacker's delight, Warren, Jr) for long and integer division and modulo by a constant divisor: https://github.com/openjdk/jdk/blob/01c0d5dd0a4f7587288219bad8ed4648f4e456ce/src/hotspot/share/opto/divnode.cpp#L161

      Other techniques/algorithms has been proposed since that might improve things, especially mod/remainder calculations. For example the one proposed by Lemire et in "Faster Remainder by Direct Computation: Applications to Compilers and Software Libraries": https://arxiv.org/abs/1902.01961 or the "modular inverse function" described by Neri in https://accu.org/journals/overload/27/154/neri_2722/

      We should examine applying either of these in C2.

            Unassigned Unassigned
            redestad Claes Redestad
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

              Created:
              Updated: