[Mlir-commits] [mlir] [mlir][affine] Modify assertion into a user visible diagnostic (PR #136474)

Mehdi Amini llvmlistbot at llvm.org
Sun Apr 20 05:39:01 PDT 2025


================
@@ -141,8 +141,14 @@ static AffineMap makePermutationMap(
     unsigned countInvariantIndices = 0;
     for (unsigned dim = 0; dim < numIndices; ++dim) {
       if (!invariants.count(indices[dim])) {
-        assert(perm[kvp.second] == getAffineConstantExpr(0, context) &&
-               "permutationMap already has an entry along dim");
+        if (perm[kvp.second] != getAffineConstantExpr(0, context)) {
+          auto loopOp = cast<affine::AffineForOp>(kvp.first);
+          loopOp->emitError(
+              "loop induction variable is used in multiple indices, which is "
+              "unsupported for vectorization. Consider using nested loops "
+              "instead of a single loop with affine.apply.");
----------------
joker-eph wrote:

If this isn't invalid IR as input, why is this triggering an error instead of just not performing the transformation?

https://github.com/llvm/llvm-project/pull/136474


More information about the Mlir-commits mailing list