[all-commits] [llvm/llvm-project] e2d291: [mlir][arith] Delete mul ext canonicalizations (#1...

Tobias Gysi via All-commits all-commits at lists.llvm.org
Thu Jun 19 23:14:02 PDT 2025


  Branch: refs/heads/users/gysit/remove-arith-ext-mul-patterns
  Home:   https://github.com/llvm/llvm-project
  Commit: e2d291fcf6732a60db323a0d6f337ce28fd997f1
      https://github.com/llvm/llvm-project/commit/e2d291fcf6732a60db323a0d6f337ce28fd997f1
  Author: Tobias Gysi <tobias.gysi at nextsilicon.com>
  Date:   2025-06-20 (Fri, 20 Jun 2025)

  Changed paths:
    M mlir/lib/Dialect/Arith/IR/ArithCanonicalization.td
    M mlir/lib/Dialect/Arith/IR/ArithOps.cpp
    M mlir/test/Dialect/Arith/canonicalize.mlir

  Log Message:
  -----------
  [mlir][arith] Delete mul ext canonicalizations (#144844)

The Arith dialect includes patterns that canonicalize a sequence of:

- trunci(shrui(mul(sext(x), sext(y)), c)) -> mulsi_extended(x, y)
- trunci(shrui(mul(zext(x), zext(y)), c)) -> mului_extended(x, y)

These patterns return the high word of an extended multiplication, which
assumes that the shift amount is equal to the bit width of the original
operands. This check was missing, leading to incorrect canonicalizations
when the shift amount was less than the bit width.

For example, the following code:
```
  %x = arith.extui %a: i32 to i33
  %y = arith.extui %b: i32 to i33
  %m = arith.muli %x, %y: i33
  %c1 = arith.constant 1: i33
  %sh = arith.shrui %m, %c1 : i33
  %hi = arith.trunci %sh: i33 to i32
```
would incorrectly be canonicalized to:
```
_, %hi = arith.mului_extended %a, %b : i32
```
This commit removes the faulty canonicalizations since they are not
believed to be generally beneficial (c.f., the discussion of the
alternative https://github.com/llvm/llvm-project/pull/144787 which fixes
the canonicalizations).



To unsubscribe from these emails, change your notification settings at https://github.com/llvm/llvm-project/settings/notifications


More information about the All-commits mailing list