[all-commits] [llvm/llvm-project] c26db5: [mlir][affine] Modify assertion into a user visibl...

Prakhar Dixit via All-commits all-commits at lists.llvm.org
Wed Apr 30 08:22:16 PDT 2025


  Branch: refs/heads/main
  Home:   https://github.com/llvm/llvm-project
  Commit: c26db586a06204a9e6f9912f41fce62a559a0196
      https://github.com/llvm/llvm-project/commit/c26db586a06204a9e6f9912f41fce62a559a0196
  Author: Prakhar Dixit <dixitprakhar11 at gmail.com>
  Date:   2025-04-30 (Wed, 30 Apr 2025)

  Changed paths:
    M mlir/lib/Dialect/Affine/Transforms/SuperVectorize.cpp
    M mlir/test/Dialect/Affine/SuperVectorize/vectorize_unsupported.mlir

  Log Message:
  -----------
  [mlir][affine] Modify assertion into a user visible diagnostic (#136474)

Fixes  #122227
The loop’s induction variable (%i) is used to compute two different
indices via affine.apply.
And the Vectorization Assumption is Violated i.e, Each vectorized loop
should contribute at most one non-invariant index.

**Minimal example crashing :**

```
#map = affine_map<(d0)[s0] -> (d0 mod s0)>
#map1 = affine_map<(d0)[s0] -> (d0 floordiv s0)>

func.func @single_loop_unrolling_2D_access_pattern(%arg0: index) -> memref<2x2xf32> {
  %c2 = arith.constant 2 : index
  %cst = arith.constant 1.0 : f32
  %alloc = memref.alloc() : memref<2x2xf32>

    affine.for %i = 0 to 4 {
      %row = affine.apply #map1(%i)[%c2]  
      %col = affine.apply #map(%i)[%c2]  
      affine.store %cst, %alloc[%row, %col] : memref<2x2xf32>
    }

    return %alloc : memref<2x2xf32>
  }
```
  
The single loop %i contributes two indices (%row and %col) to the 2D
memref access.

The permutation map expects one index per vectorized loop dimension, but
here one loop (%i) maps to two indices (dim=0 and dim=1).

The code detects this when trying to assign the second index (dim=1) to
the same vector dimension (perm[0]).



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