[PATCH] D31968: Remove all allocation and divisions from GreatestCommonDivisor

Richard Smith via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Tue Apr 11 18:17:44 PDT 2017


rsmith created this revision.

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.


Repository:
  rL LLVM

https://reviews.llvm.org/D31968

Files:
  include/llvm/ADT/APInt.h
  lib/Support/APInt.cpp
  unittests/ADT/APIntTest.cpp

-------------- next part --------------
A non-text attachment was scrubbed...
Name: D31968.94920.patch
Type: text/x-patch
Size: 8101 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20170412/07af124c/attachment.bin>


More information about the llvm-commits mailing list