[llvm] [mlir] [ADT] Add implementations for mulhs and mulhu to APInt (PR #84609)
    Shourya Goel via llvm-commits 
    llvm-commits at lists.llvm.org
       
    Sat Mar  9 13:39:57 PST 2024
    
    
  
================
@@ -433,11 +433,8 @@ arith::MulSIExtendedOp::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.sext(bitWidth * 2) * b.sext(bitWidth * 2);
-          return fullProduct.extractBits(bitWidth, bitWidth);
-        });
+        adaptor.getOperands(),
+        [](const APInt &a, const APInt &b) { return APIntOps::mulhs(a, b); });
----------------
Sh0g0-1758 wrote:
done. 
https://github.com/llvm/llvm-project/pull/84609
    
    
More information about the llvm-commits
mailing list