Skip to content

Commit 4c3169d

Browse files
authored
[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.
1 parent 65683b0 commit 4c3169d

File tree

2 files changed

+13
-3
lines changed

2 files changed

+13
-3
lines changed

mlir/lib/Dialect/Arith/Transforms/EmulateWideInt.cpp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1044,9 +1044,9 @@ struct EmulateWideIntPass final
10441044
return typeConverter.isLegal(op);
10451045
};
10461046
target.addDynamicallyLegalOp<func::CallOp, func::ReturnOp>(opLegalCallback);
1047-
target
1048-
.addDynamicallyLegalDialect<arith::ArithDialect, vector::VectorDialect>(
1049-
opLegalCallback);
1047+
target.addDynamicallyLegalOp<vector::PrintOp>(opLegalCallback);
1048+
target.addDynamicallyLegalDialect<arith::ArithDialect>(opLegalCallback);
1049+
target.addLegalDialect<vector::VectorDialect>();
10501050

10511051
RewritePatternSet patterns(ctx);
10521052
arith::populateArithWideIntEmulationPatterns(typeConverter, patterns);

mlir/test/Dialect/Arith/emulate-wide-int-unsupported.mlir

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -41,3 +41,13 @@ func.func @unsupported_argument_type(%arg0: vector<4xi128>) -> vector<4xi64> {
4141
return %0 : vector<4xi64>
4242
}
4343

44+
// -----
45+
46+
// Ensure this case not crash
47+
func.func @unsupported_vector(%arg0: vector<2xi1>) {
48+
// expected-error@+1 {{failed to legalize unresolved materialization from ('vector<2x2xi32>') to ('vector<2xi64>') that remained live after conversion}}
49+
%cst_0 = arith.constant dense<0> : vector<2xi64>
50+
// expected-note@+1 {{see existing live user here}}
51+
%0 = vector.mask %arg0 { vector.multi_reduction <xor>, %cst_0, %cst_0 [] : vector<2xi64> to vector<2xi64> } : vector<2xi1> -> vector<2xi64>
52+
return
53+
}

0 commit comments

Comments
 (0)