[all-commits] [llvm/llvm-project] 8165ea: [mlir](arithmetic) Add ceildivui to the arithmetic...

long.chen via All-commits all-commits at lists.llvm.org
Wed Nov 10 17:49:27 PST 2021


  Branch: refs/heads/main
  Home:   https://github.com/llvm/llvm-project
  Commit: 8165eaa8853195e3211cb84b77083c3f10adcb5e
      https://github.com/llvm/llvm-project/commit/8165eaa8853195e3211cb84b77083c3f10adcb5e
  Author: lipracer <lipracer at gmail.com>
  Date:   2021-11-11 (Thu, 11 Nov 2021)

  Changed paths:
    M mlir/include/mlir/Dialect/Arithmetic/IR/ArithmeticOps.td
    M mlir/lib/Dialect/Arithmetic/IR/ArithmeticOps.cpp
    M mlir/lib/Dialect/Arithmetic/Transforms/ExpandOps.cpp
    M mlir/lib/Dialect/StandardOps/Transforms/ExpandOps.cpp
    M mlir/test/Dialect/Arithmetic/expand-ops.mlir
    M mlir/test/Integration/Dialect/Standard/CPU/test-ceil-floor-pos-neg.mlir
    M mlir/test/Transforms/canonicalize.mlir
    M mlir/test/Transforms/constant-fold.mlir

  Log Message:
  -----------
  [mlir](arithmetic) Add ceildivui to the arithmetic dialect

The specific description is [[ https://llvm.discourse.group/t/adding-unsigned-integer-ceil-and-floor-in-std-dialect/4541 | Adding unsigned integer ceil in Std Dialect ]] .

When we lower ceilDivOp this will generate below code, sometimes we know m and n are unsigned intergal.Here are some redundant judgments about positive and negative.
So we need to add some unsigned operations to simplify the instructions.
```
ceilDiv(n, m)
  x = (m > 0) ? -1 : 1
  return (n*m>0) ? ((n+x) / m) + 1 : - (-n / m)
```
unsigned operations:
```
ceilDivU(n, m)
  return n ==0 ?  0 :  ((n - 1) / m) + 1
```

Reviewed By: Mogball

Differential Revision: https://reviews.llvm.org/D113363




More information about the All-commits mailing list