[llvm] r300252 - Remove all allocation and divisions from GreatestCommonDivisor

Hans Wennborg via llvm-commits llvm-commits at lists.llvm.org
Thu Apr 13 13:50:34 PDT 2017


On Thu, Apr 13, 2017 at 1:29 PM, Richard Smith via llvm-commits
<llvm-commits at lists.llvm.org> wrote:
> Author: rsmith
> Date: Thu Apr 13 15:29:59 2017
> New Revision: 300252
>
> URL: http://llvm.org/viewvc/llvm-project?rev=300252&view=rev
> Log:
> Remove all allocation and divisions from GreatestCommonDivisor
>
> Switch from Euclid's algorithm to Stein's algorithm for computing GCD. This
> avoids the (expensive) APInt division operation in favour of bit operations.
> Remove all memory allocation from within the GCD loop by tweaking our `lshr`
> implementation so it can operate in-place.

Cool!

> -/// \brief Compute GCD of two APInt values.
> +/// \brief Compute GCD of two unsigned APInt values.
>  ///
>  /// This function returns the greatest common divisor of the two APInt values
>  /// using Euclid's algorithm.

s/Euclid/Stein/ here?


More information about the llvm-commits mailing list