Skip to content

Commit 9baa414

Browse files
authored
[libc][NFC] Simplify BigInt::mul (llvm#84468)
1 parent 7457e2c commit 9baa414

File tree

1 file changed

+1
-3
lines changed

1 file changed

+1
-3
lines changed

libc/src/__support/UInt.h

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -262,15 +262,13 @@ struct BigInt {
262262
// Returns the carry value produced by the multiplication operation.
263263
LIBC_INLINE constexpr WordType mul(WordType x) {
264264
BigInt<2 * WORD_SIZE, Signed, WordType> partial_sum(0);
265-
WordType carry = 0;
266265
for (size_t i = 0; i < WORD_COUNT; ++i) {
267266
NumberPair<WordType> prod = full_mul(val[i], x);
268267
BigInt<2 * WORD_SIZE, Signed, WordType> tmp({prod.lo, prod.hi});
269-
carry += partial_sum.add(tmp);
268+
const WordType carry = partial_sum.add(tmp);
270269
val[i] = partial_sum.val[0];
271270
partial_sum.val[0] = partial_sum.val[1];
272271
partial_sum.val[1] = carry;
273-
carry = 0;
274272
}
275273
return partial_sum.val[1];
276274
}

0 commit comments

Comments
 (0)