[Mlir-commits] [mlir] [mlir][arith] Add overflow flags support to arith ops (PR #77211)

Jakub Kuderski llvmlistbot at llvm.org
Sun Jan 7 15:01:14 PST 2024


================
@@ -302,21 +345,41 @@ def Arith_SubIOp : Arith_TotalIntBinaryOp<"subi"> {
 // MulIOp
 //===----------------------------------------------------------------------===//
 
-def Arith_MulIOp : Arith_TotalIntBinaryOp<"muli", [Commutative]> {
+def Arith_MulIOp : Arith_IntArithmeticOpWithOverflowFlag<"muli", [Commutative]> {
   let summary = [{
     Integer multiplication operation.
   }];
   let description = [{
-    Performs N-bit multiplication on the operands. The operands are interpreted as 
-    unsigned bitvectors. The result is represented by a bitvector containing the 
-    mathematical value of the multiplication modulo 2^n, where `n` is the bitwidth. 
-    Because `arith` integers use a two's complement representation, this operation is 
+    Performs N-bit multiplication on the operands. The operands are interpreted as
+    unsigned bitvectors. The result is represented by a bitvector containing the
+    mathematical value of the multiplication modulo 2^n, where `n` is the bitwidth.
+    Because `arith` integers use a two's complement representation, this operation is
     applicable on both signed and unsigned integer operands.
 
     The `muli` operation takes two operands and returns one result, each of
-    these is required to be the same type. This type may be an integer scalar type, 
-    a vector whose element type is integer, or a tensor of integers. It has no 
-    standard attributes.    
+    these is required to be the same type. This type may be an integer scalar type,
+    a vector whose element type is integer, or a tensor of integers.
+
+    This op supports nuw/nsw flags which stands stand for "No Unsigned Wrap" and
+    "No Signed Wrap", respectively. If the nuw and/or nsw flags are present, the
+    result value is undefined if unsigned and/or signed overflow, respectively,
+    occurs.
----------------
kuhar wrote:

```suggestion
    This op supports `nuw`/`nsw` overflow flags which stands stand for "No Unsigned Wrap"
    and "No Signed Wrap", respectively. If the `nuw` and/or `nsw` flags are present,
    and an unsigned/signed overflow occurs (respectively), the result is poison.
```

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


More information about the Mlir-commits mailing list