[Mlir-commits] [mlir] [mlir][arith] EmulateWideInt only support `vector.print` (PR #124510)
Longsheng Mou
llvmlistbot at llvm.org
Sun Jan 26 22:23:09 PST 2025
https://github.com/CoTinker created https://github.com/llvm/llvm-project/pull/124510
This PR fixes a bug where dynamically legal operations were added for all vector operations, but only `vector.print` was supported, leading to a crash. Fixes #73381.
>From 95c12b0ca7e67e41fb4d777224ccd6ca3ee6a1a1 Mon Sep 17 00:00:00 2001
From: Longsheng Mou <longshengmou at gmail.com>
Date: Mon, 27 Jan 2025 11:29:50 +0800
Subject: [PATCH 1/2] [mlir][arith] EmulateWideInt only support `vector.print`
This PR fixes a bug where dynamically legal operations were added for all vector dialects, but only `vector.print` was supported, leading to a crash.
---
mlir/lib/Dialect/Arith/Transforms/EmulateWideInt.cpp | 6 +++---
1 file changed, 3 insertions(+), 3 deletions(-)
diff --git a/mlir/lib/Dialect/Arith/Transforms/EmulateWideInt.cpp b/mlir/lib/Dialect/Arith/Transforms/EmulateWideInt.cpp
index 2d49854347d406..61f8d82a615d89 100644
--- a/mlir/lib/Dialect/Arith/Transforms/EmulateWideInt.cpp
+++ b/mlir/lib/Dialect/Arith/Transforms/EmulateWideInt.cpp
@@ -1044,9 +1044,9 @@ struct EmulateWideIntPass final
return typeConverter.isLegal(op);
};
target.addDynamicallyLegalOp<func::CallOp, func::ReturnOp>(opLegalCallback);
- target
- .addDynamicallyLegalDialect<arith::ArithDialect, vector::VectorDialect>(
- opLegalCallback);
+ target.addDynamicallyLegalOp<vector::PrintOp>(opLegalCallback);
+ target.addDynamicallyLegalDialect<arith::ArithDialect>(opLegalCallback);
+ target.addLegalDialect<vector::VectorDialect>();
RewritePatternSet patterns(ctx);
arith::populateArithWideIntEmulationPatterns(typeConverter, patterns);
>From 00bd6f8b52f0732f48179ef6f35d90511670212b Mon Sep 17 00:00:00 2001
From: Longsheng Mou <longshengmou at gmail.com>
Date: Mon, 27 Jan 2025 14:08:45 +0800
Subject: [PATCH 2/2] add test
---
.../Dialect/Arith/emulate-wide-int-unsupported.mlir | 10 ++++++++++
1 file changed, 10 insertions(+)
diff --git a/mlir/test/Dialect/Arith/emulate-wide-int-unsupported.mlir b/mlir/test/Dialect/Arith/emulate-wide-int-unsupported.mlir
index 091dd15dcd8517..44f09b920ed4f5 100644
--- a/mlir/test/Dialect/Arith/emulate-wide-int-unsupported.mlir
+++ b/mlir/test/Dialect/Arith/emulate-wide-int-unsupported.mlir
@@ -41,3 +41,13 @@ func.func @unsupported_argument_type(%arg0: vector<4xi128>) -> vector<4xi64> {
return %0 : vector<4xi64>
}
+// -----
+
+// Ensure this case not crash
+func.func @unsupported_vector(%arg0: vector<2xi1>) {
+ // expected-error at +1 {{failed to legalize unresolved materialization from ('vector<2x2xi32>') to ('vector<2xi64>') that remained live after conversion}}
+ %cst_0 = arith.constant dense<0> : vector<2xi64>
+ // expected-note at +1 {{see existing live user here}}
+ %0 = vector.mask %arg0 { vector.multi_reduction <xor>, %cst_0, %cst_0 [] : vector<2xi64> to vector<2xi64> } : vector<2xi1> -> vector<2xi64>
+ return
+}
More information about the Mlir-commits
mailing list