[Mlir-commits] [llvm] [mlir] [ADT] Add implementations for mulhs and mulhu to APInt (PR #84609)
Jakub Kuderski
llvmlistbot at llvm.org
Sat Mar 9 13:26:52 PST 2024
================
@@ -2193,6 +2193,16 @@ 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
+/// Mathematically, this computes the value: (C1 * C2) >> C2.getBitWidth()
+/// where (C1 * C2) has double the bit width of the original values.
+APInt mulhu(const APInt &C1, const APInt &C2);
+
+/// Compute the higher order bits of signed multiplication of two APInts
+/// Mathematically, this is similar to mulhu but for signed values.
+/// Example: mulhs(-2097152,524288) == -256
----------------
kuhar wrote:
```suggestion
/// Mathematically, this is similar to mulhu but for signed values.
/// Example: `mulhs(-2097152, 524288) == -256`
```
https://github.com/llvm/llvm-project/pull/84609
More information about the Mlir-commits
mailing list