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

Craig Topper via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Tue Apr 11 20:41:34 PDT 2017


craig.topper added a comment.

Can we just merge lshrNear fully into lshrInPlace and just use lshrInPlace in the other place that uses lshrNear?



================
Comment at: lib/Support/APInt.cpp:776
+/// we require that Src >= Dst (put another way, we require that the overall
+/// operation is a right shift).
 static void lshrNear(uint64_t *Dst, uint64_t *Src, unsigned Words,
----------------
Should we add an assert that Shift is less than APINT_BITS_PER_WORD?


================
Comment at: lib/Support/APInt.cpp:783
+  if (Shift == 0) {
+    std::memmove(Dst, Src, Words * 8);
+    return;
----------------
Use APINT_WORD_SIZE instead of 8.


================
Comment at: lib/Support/APInt.cpp:790
+    uint64_t High = Src[I];
+    Dst[I - 1] = (Low >> Shift) | (High << (64 - Shift));
+    Low = High;
----------------
Use APINT_BITS_PER_WORD instead of 64.


================
Comment at: lib/Support/APInt.cpp:1221
+  const unsigned Words = getNumWords();
+  const unsigned ShiftFullWords = std::min(shiftAmt >> 6, Words);
+
----------------
Can we divide by APINT_BITS_PER_WORD and let the compiler optimize to shift?


================
Comment at: lib/Support/APInt.cpp:1225
+  lshrNear(pVal, pVal + ShiftFullWords, Words - ShiftFullWords,
+           shiftAmt - (ShiftFullWords << 6));
+
----------------
Multiply by APINT_BITS_PER_WORD instead of shifting by 6.


Repository:
  rL LLVM

https://reviews.llvm.org/D31968





More information about the llvm-commits mailing list