Skip to content

Commit cda887a

Browse files
committed
Add test for single-element vectors
1 parent fba473f commit cda887a

File tree

1 file changed

+11
-1
lines changed

1 file changed

+11
-1
lines changed

mlir/test/Conversion/ArithToSPIRV/arith-to-spirv.mlir

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -744,7 +744,17 @@ func.func @index_casti1index_1(%arg0 : i1) {
744744
}
745745

746746
// CHECK-LABEL: index_casti1index_2
747-
func.func @index_casti1index_2(%arg0 : vector<3xi1>) {
747+
func.func @index_casti1index_2(%arg0 : vector<1xi1>) -> vector<1xindex> {
748+
// Single-element vectors do not exist in SPIRV.
749+
// CHECK: %[[ZERO:.+]] = spirv.Constant 0 : i32
750+
// CHECK: %[[ONE:.+]] = spirv.Constant 1 : i32
751+
// CHECK: spirv.Select %{{.+}}, %[[ONE]], %[[ZERO]] : i1, i32
752+
%0 = arith.index_cast %arg0 : vector<1xi1> to vector<1xindex>
753+
return %0 : vector<1xindex>
754+
}
755+
756+
// CHECK-LABEL: index_casti1index_3
757+
func.func @index_casti1index_3(%arg0 : vector<3xi1>) {
748758
// CHECK: %[[ZERO:.+]] = spirv.Constant dense<0> : vector<3xi32>
749759
// CHECK: %[[ONE:.+]] = spirv.Constant dense<1> : vector<3xi32>
750760
// CHECK: spirv.Select %{{.+}}, %[[ONE]], %[[ZERO]] : vector<3xi1>, vector<3xi32>

0 commit comments

Comments
 (0)