From 2c217b27af039385e77826d05f4c2ff91c8653c6 Mon Sep 17 00:00:00 2001 From: jeonghm9764 Date: Fri, 14 Nov 2025 22:27:59 -0600 Subject: [PATCH 1/2] [MLIR] Fix affine SSA id parser for values with numbers --- mlir/lib/AsmParser/AffineParser.cpp | 7 ------- 1 file changed, 7 deletions(-) diff --git a/mlir/lib/AsmParser/AffineParser.cpp b/mlir/lib/AsmParser/AffineParser.cpp index 1797611858c06..8f7fa3877aa18 100644 --- a/mlir/lib/AsmParser/AffineParser.cpp +++ b/mlir/lib/AsmParser/AffineParser.cpp @@ -311,13 +311,6 @@ AffineExpr AffineParser::parseSSAIdExpr(bool isSymbol) { if (getToken().isNot(Token::percent_identifier)) return emitWrongTokenError("expected ssa identifier"), nullptr; auto name = getTokenSpelling(); - // Check if we already parsed this SSA id. - for (auto entry : dimsAndSymbols) { - if (entry.first == name) { - consumeToken(Token::percent_identifier); - return entry.second; - } - } // Parse the SSA id and add an AffineDim/SymbolExpr to represent it. if (parseElement(isSymbol)) return nullptr; From 05d8297ebd6edaf254c33589942feeba8d242fa1 Mon Sep 17 00:00:00 2001 From: jeonghm9764 Date: Mon, 17 Nov 2025 21:07:27 -0600 Subject: [PATCH 2/2] [MLIR] Add test for the fix --- mlir/test/Dialect/Affine/load-store.mlir | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/mlir/test/Dialect/Affine/load-store.mlir b/mlir/test/Dialect/Affine/load-store.mlir index e214a0815746d..247bbe89fe382 100644 --- a/mlir/test/Dialect/Affine/load-store.mlir +++ b/mlir/test/Dialect/Affine/load-store.mlir @@ -198,6 +198,20 @@ func.func @test_prefetch(%arg0 : index, %arg1 : index) { // ----- +// Test with load affine map with same SSA name. +func.func @test_load_same_ssa_name() { + %0 = memref.alloc() : memref<10x10xf32> + affine.for %i0 = 0 to 100 { + %i2:2 = affine.delinearize_index %i0 into (10, 10) : index, index + %1 = affine.load %0[%i2#0, %i2#1] : memref<10x10xf32> + // CHECK: %{{.*}} = affine.load %{{.*}}[%{{.*}}, %{{.*}}] : memref<10x10xf32> + affine.store %1, %0[%i2#0, %i2#1] : memref<10x10xf32> + } + return +} + +// ----- + // Test with just loop IVs. func.func @vector_load_vector_store_iv() { %0 = memref.alloc() : memref<100x100xf32>