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

Shourya Goel llvmlistbot at llvm.org
Sat Mar 9 13:39:52 PST 2024


================
@@ -490,11 +487,8 @@ arith::MulUIExtendedOp::fold(FoldAdaptor adaptor,
           [](const APInt &a, const APInt &b) { return a * b; })) {
     // Invoke the constant fold helper again to calculate the 'high' result.
     Attribute highAttr = constFoldBinaryOp<IntegerAttr>(
-        adaptor.getOperands(), [](const APInt &a, const APInt &b) {
-          unsigned bitWidth = a.getBitWidth();
-          APInt fullProduct = a.zext(bitWidth * 2) * b.zext(bitWidth * 2);
-          return fullProduct.extractBits(bitWidth, bitWidth);
-        });
+        adaptor.getOperands(),
+        [](const APInt &a, const APInt &b) { return APIntOps::mulhu(a, b); });
----------------
Sh0g0-1758 wrote:

done. 

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


More information about the Mlir-commits mailing list