[llvm] Revert "[APInt] Remove multiplicativeInverse with explicit modulus (#… (PR #87812)
Jay Foad via llvm-commits
llvm-commits at lists.llvm.org
Fri Apr 5 11:09:45 PDT 2024
================
@@ -1240,6 +1240,55 @@ APInt APInt::sqrt() const {
return x_old + 1;
}
+/// Computes the multiplicative inverse of this APInt for a given modulo. The
+/// iterative extended Euclidean algorithm is used to solve for this value,
+/// however we simplify it to speed up calculating only the inverse, and take
+/// advantage of div+rem calculations. We also use some tricks to avoid copying
+/// (potentially large) APInts around.
+/// WARNING: a value of '0' may be returned,
----------------
jayfoad wrote:
This comment seems alarmist. I would prefer "Computes the multiplicative inverse of this APInt for a given modulus, or 0 if no such inverse exists."
https://github.com/llvm/llvm-project/pull/87812
More information about the llvm-commits
mailing list