[all-commits] [llvm/llvm-project] 8c74dc: [MLIR][Affine] Fix affine.apply verifier and add f...

Uday Bondhugula via All-commits all-commits at lists.llvm.org
Tue Apr 22 16:42:00 PDT 2025


  Branch: refs/heads/main
  Home:   https://github.com/llvm/llvm-project
  Commit: 8c74dc1adf83d370e740e44ffe073487fd3b38d2
      https://github.com/llvm/llvm-project/commit/8c74dc1adf83d370e740e44ffe073487fd3b38d2
  Author: Uday Bondhugula <uday at polymagelabs.com>
  Date:   2025-04-23 (Wed, 23 Apr 2025)

  Changed paths:
    M mlir/include/mlir/Dialect/Affine/IR/AffineOps.td
    M mlir/lib/Dialect/Affine/IR/AffineOps.cpp
    M mlir/test/Dialect/Affine/canonicalize.mlir
    M mlir/test/Dialect/Affine/invalid.mlir
    M mlir/test/Dialect/MemRef/fold-memref-alias-ops.mlir

  Log Message:
  -----------
  [MLIR][Affine] Fix affine.apply verifier and add functionality to demote invalid symbols to dims (#128289)

Fixes: https://github.com/llvm/llvm-project/issues/120189,
https://github.com/llvm/llvm-project/issues/128403

Fix affine.apply verifier to reject symbolic operands that are valid
dims for affine purposes. This doesn't affect other users in other
contexts where the operands were neither valid dims or symbols (for eg.
in scf.for or other region ops). Otherwise, it was possible for
`-canonicalize` to have generated invalid IR when such
affine.apply ops were composed.

Introduce a method to demote a symbolic operand to a dimensional one
(the inverse of the current canonicalizePromotedSymbols).  Demote
operands that could/should have been valid affine dimensional values
(affine loop IVs or their functions) from symbols to dims. This is a
general method that can be used to legalize a map + operands post
construction depending on its operands. Use it during
`canonicalizeMapOrSetAndOperands` so that pattern rewriter-based passes
are able to generate valid IR post folding. Users outside of affine
analyses/dialects remain unaffected.

In some cases, this change also leads to better simplified operands,
duplicates eliminated as shown in one of the test cases where the same
operand appeared as a symbol and as a dim.

This commit also fixes test cases where dimensional positions should have
been ideally used with affine.apply (for affine loop IVs for example).



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