[all-commits] [llvm/llvm-project] 8934b1: [mlir][arith] Add overflow flags support to arith ...

Jacques Pienaar via All-commits all-commits at lists.llvm.org
Tue Jan 16 19:12:35 PST 2024


  Branch: refs/heads/main
  Home:   https://github.com/llvm/llvm-project
  Commit: 8934b10642664c0824f45f115b2a0afcb56a5e5f
      https://github.com/llvm/llvm-project/commit/8934b10642664c0824f45f115b2a0afcb56a5e5f
  Author: Jacques Pienaar <jpienaar at google.com>
  Date:   2024-01-17 (Wed, 17 Jan 2024)

  Changed paths:
    M mlir/include/mlir/Conversion/ArithCommon/AttrToLLVMConverter.h
    M mlir/include/mlir/Dialect/Arith/IR/ArithBase.td
    M mlir/include/mlir/Dialect/Arith/IR/ArithOps.td
    M mlir/include/mlir/Dialect/Arith/IR/ArithOpsInterfaces.td
    M mlir/include/mlir/Dialect/LLVMIR/LLVMInterfaces.td
    M mlir/lib/Conversion/ArithCommon/AttrToLLVMConverter.cpp
    M mlir/lib/Conversion/ArithToLLVM/ArithToLLVM.cpp
    M mlir/lib/Conversion/ArithToSPIRV/ArithToSPIRV.cpp
    M mlir/lib/Dialect/Arith/IR/ArithCanonicalization.td
    M mlir/lib/Dialect/Arith/IR/ArithOps.cpp
    M mlir/test/Conversion/ArithToLLVM/arith-to-llvm.mlir
    M mlir/test/Conversion/ArithToSPIRV/arith-to-spirv.mlir
    M mlir/test/Dialect/Arith/ops.mlir
    A mlir/test/python/dialects/arith_llvm.py
    M mlir/test/python/ir/diagnostic_handler.py

  Log Message:
  -----------
  [mlir][arith] Add overflow flags support to arith ops (#78376)

Add overflow flags support to the following ops:
* `arith.addi`
* `arith.subi`
* `arith.muli`

Example of new syntax:
```
%res = arith.addi %arg1, %arg2 overflow<nsw> : i64
```
Similar to existing LLVM dialect syntax
```
%res = llvm.add %arg1, %arg2 overflow<nsw> : i64
```

Tablegen canonicalization patterns updated to always drop flags, proper
support with tests will be added later.

Updated LLVMIR translation as part of this commit as it currenly written
in a way that it will crash when new attributes added to arith ops
otherwise.

Also lower `arith` overflow flags to corresponding SPIR-V op decorations

Discussion

https://discourse.llvm.org/t/rfc-integer-overflow-flags-support-in-arith-dialect/76025

This effectively rolls forward #77211, #77700 and #77714 while adding a
test to ensure the Python usage is not broken. More follow up needed but
unrelated to the core change here. The changes here are minimal and just
correspond to "textual namespacing" ODS side, no C++ or Python changes
were needed.

---------

---------

Co-authored-by: Ivan Butygin <ivan.butygin at gmail.com>, Yi Wu <yi.wu2 at arm.com>




More information about the All-commits mailing list