[llvm] [ADT] Add implementations for mulhs and mulhu to APInt (PR #84609)

Jakub Kuderski via llvm-commits llvm-commits at lists.llvm.org
Sat Mar 9 12:33:55 PST 2024


================
@@ -2193,6 +2193,12 @@ inline const APInt absdiff(const APInt &A, const APInt &B) {
   return A.uge(B) ? (A - B) : (B - A);
 }
 
+/// Compute the higher order bits of unsigned multiplication of two APInts
+APInt mulhu(const APInt &C1, const APInt &C2);
----------------
kuhar wrote:

Ah sorry, what I wrote is the definition of low-order bits. I meant: `(C1 * C2) % Max(C2)` or `(C1 * C2) >> bitwidth(C2)`. My point is that I'd appreciate if the documentation explained what's being calculated, and having the exact formula would help.

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


More information about the llvm-commits mailing list