diff --git a/mlir/lib/Conversion/StandardToSPIRV/ConvertStandardToSPIRV.cpp b/mlir/lib/Conversion/StandardToSPIRV/ConvertStandardToSPIRV.cpp --- a/mlir/lib/Conversion/StandardToSPIRV/ConvertStandardToSPIRV.cpp +++ b/mlir/lib/Conversion/StandardToSPIRV/ConvertStandardToSPIRV.cpp @@ -867,6 +867,7 @@ BoolCmpIOpPattern, ConstantCompositeOpPattern, ConstantScalarOpPattern, CmpFOpPattern, CmpIOpPattern, IntLoadOpPattern, LoadOpPattern, ReturnOpPattern, SelectOpPattern, IntStoreOpPattern, StoreOpPattern, + TypeCastingOpPattern, TypeCastingOpPattern, TypeCastingOpPattern, TypeCastingOpPattern, diff --git a/mlir/test/Conversion/StandardToSPIRV/std-ops-to-spirv.mlir b/mlir/test/Conversion/StandardToSPIRV/std-ops-to-spirv.mlir --- a/mlir/test/Conversion/StandardToSPIRV/std-ops-to-spirv.mlir +++ b/mlir/test/Conversion/StandardToSPIRV/std-ops-to-spirv.mlir @@ -461,6 +461,34 @@ max_compute_workgroup_size = dense<[128, 128, 64]> : vector<3xi32>}> } { +// CHECK-LABEL: index_cast1 +func @index_cast1(%arg0: i16) { + // CHECK: spv.SConvert %{{.+}} : i16 to i32 + %0 = index_cast %arg0 : i16 to index + return +} + +// CHECK-LABEL: index_cast2 +func @index_cast2(%arg0: index) { + // CHECK: spv.SConvert %{{.+}} : i32 to i16 + %0 = index_cast %arg0 : index to i16 + return +} + +// CHECK-LABEL: index_cast3 +func @index_cast3(%arg0: i32) { + // CHECK-NOT: spv.SConvert + %0 = index_cast %arg0 : i32 to index + return +} + +// CHECK-LABEL: index_cast4 +func @index_cast4(%arg0: index) { + // CHECK-NOT: spv.SConvert + %0 = index_cast %arg0 : index to i32 + return +} + // CHECK-LABEL: @fpext1 func @fpext1(%arg0: f16) -> f64 { // CHECK: spv.FConvert %{{.*}} : f16 to f64