[Mlir-commits] [mlir] 4c3169d - [mlir][arith] EmulateWideInt only support `vector.print` (#124510)

llvmlistbot at llvm.org llvmlistbot at llvm.org
Tue Feb 4 17:43:46 PST 2025


Author: Longsheng Mou
Date: 2025-02-05T09:43:42+08:00
New Revision: 4c3169d24c9ed5851799af509b295f8723ffd627

URL: https://github.com/llvm/llvm-project/commit/4c3169d24c9ed5851799af509b295f8723ffd627
DIFF: https://github.com/llvm/llvm-project/commit/4c3169d24c9ed5851799af509b295f8723ffd627.diff

LOG: [mlir][arith] EmulateWideInt only support `vector.print` (#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.

Added: 
    

Modified: 
    mlir/lib/Dialect/Arith/Transforms/EmulateWideInt.cpp
    mlir/test/Dialect/Arith/emulate-wide-int-unsupported.mlir

Removed: 
    


################################################################################
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);

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