Skip to content

Commit fcd505d

Browse files
committed
[arith] Allow integer casts of 0-D vectors
This just works, no reason to disallow it. Differential Revision: https://reviews.llvm.org/D142137
1 parent ebd9a24 commit fcd505d

File tree

2 files changed

+13
-1
lines changed

2 files changed

+13
-1
lines changed

mlir/include/mlir/Dialect/Arith/IR/ArithOps.td

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -102,7 +102,7 @@ class Arith_CastOp<string mnemonic, TypeConstraint From, TypeConstraint To,
102102
// excluding indices: signless integers, vectors or tensors thereof.
103103
def SignlessFixedWidthIntegerLike : TypeConstraint<Or<[
104104
AnySignlessInteger.predicate,
105-
VectorOf<[AnySignlessInteger]>.predicate,
105+
VectorOfAnyRankOf<[AnySignlessInteger]>.predicate,
106106
TensorOf<[AnySignlessInteger]>.predicate]>,
107107
"signless-fixed-width-integer-like">;
108108

mlir/test/Conversion/ArithToLLVM/arith-to-llvm.mlir

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -297,6 +297,18 @@ func.func @integer_extension_and_truncation(%arg0 : i3) {
297297
return
298298
}
299299

300+
// CHECK-LABEL: @integer_cast_0d_vector
301+
func.func @integer_cast_0d_vector(%arg0 : vector<i3>) {
302+
// CHECK: %[[ARG0:.*]] = builtin.unrealized_conversion_cast
303+
// CHECK-NEXT: = llvm.sext %[[ARG0]] : vector<1xi3> to vector<1xi6>
304+
%0 = arith.extsi %arg0 : vector<i3> to vector<i6>
305+
// CHECK-NEXT: = llvm.zext %[[ARG0]] : vector<1xi3> to vector<1xi6>
306+
%1 = arith.extui %arg0 : vector<i3> to vector<i6>
307+
// CHECK-NEXT: = llvm.trunc %[[ARG0]] : vector<1xi3> to vector<1xi2>
308+
%2 = arith.trunci %arg0 : vector<i3> to vector<i2>
309+
return
310+
}
311+
300312
// CHECK-LABEL: func @fcmp(%arg0: f32, %arg1: f32) {
301313
func.func @fcmp(f32, f32) -> () {
302314
^bb0(%arg0: f32, %arg1: f32):

0 commit comments

Comments
 (0)