[llvm] [SCEV] Fix BinomialCoefficient Iteration to fit in W bits (PR #88010)

Craig Topper via llvm-commits llvm-commits at lists.llvm.org
Mon Apr 8 13:11:01 PDT 2024


================
@@ -928,10 +928,9 @@ static const SCEV *BinomialCoefficient(const SCEV *It, unsigned K,
   APInt OddFactorial(W, 1);
   unsigned T = 1;
   for (unsigned i = 3; i <= K; ++i) {
-    APInt Mult(W, i);
-    unsigned TwoFactors = Mult.countr_zero();
+    unsigned TwoFactors = countr_zero(i);
     T += TwoFactors;
-    Mult.lshrInPlace(TwoFactors);
+    APInt Mult(W, i >> TwoFactors);
----------------
topperc wrote:

Why can't we use the `uint64_t` overload of operator*= on the next line?

https://github.com/llvm/llvm-project/pull/88010


More information about the llvm-commits mailing list