Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Optimize integer arithmetic #7553

Merged
merged 7 commits into from
Aug 21, 2023
Merged

Commits on Aug 18, 2023

  1. Configuration menu
    Copy the full SHA
    a64f45d View commit details
    Browse the repository at this point in the history
  2. Fuse multiplication with addition

    Fuse a multiplication operator followed by an addition operator.
    That will generally reduce the number of instructions compared
    to having separate operators.
    bjorng committed Aug 18, 2023
    Configuration menu
    Copy the full SHA
    6a02b04 View commit details
    Browse the repository at this point in the history
  3. Optimize division by powers of two

    We used to replace division by a power of two with a right shift
    only when the dividend was known to be a positive integer. Extend
    the implementation to do right shift when the range of the dividend
    is unknown.
    bjorng committed Aug 18, 2023
    Configuration menu
    Copy the full SHA
    16dacd0 View commit details
    Browse the repository at this point in the history
  4. Optimize bsr for small operands

    Inline the code for right shift a small operand any number steps.
    We used to call a helper routine when the shift count exceeded the
    number of bits in a small.
    bjorng committed Aug 18, 2023
    Configuration menu
    Copy the full SHA
    55813dd View commit details
    Browse the repository at this point in the history
  5. Configuration menu
    Copy the full SHA
    8cab1c6 View commit details
    Browse the repository at this point in the history
  6. Optimize squaring of big integers

    The routine for squaring a big integer did not have all optimizations
    that the multiplication routine had.
    bjorng committed Aug 18, 2023
    Configuration menu
    Copy the full SHA
    4253b86 View commit details
    Browse the repository at this point in the history
  7. Optimize the implementation of the Karatsuba algorithm

    This commit implements the Karatsuba algorithm in a way
    that reduces the number of additions, resulting in a measureable
    performance improvement for multiplication of large integers.
    bjorng committed Aug 18, 2023
    Configuration menu
    Copy the full SHA
    4ca352e View commit details
    Browse the repository at this point in the history