@@ -137,20 +137,22 @@ func.func @negative_broadcast_transpose_021(%arg0 : vector<3x1x3xi8>) -> vector<
137137 return %1 : vector <3 x3 x3 xi8 >
138138}
139139
140-
141140// -----
142141
143- // Test of FoldTransposeShapeCast
142+ /// +--------------------------------------------------------------------------
143+ /// Tests of ShapeCastOp::fold: shape_cast(transpose) -> shape_cast
144+ /// +--------------------------------------------------------------------------
145+
144146// In this test, the permutation maps the non-unit dimensions (1 and 2) as follows:
145147// 1 -> 0
146148// 2 -> 4
147149// Because 0 < 4, this permutation is order preserving and effectively a shape_cast.
148- // CHECK-LABEL: @transpose_shape_cast
150+ // CHECK-LABEL: @shape_cast_of_transpose
149151// CHECK-SAME: %[[ARG:.*]]: vector<1x4x4x1x1xi8>) -> vector<4x4xi8> {
150152// CHECK: %[[SHAPE_CAST:.*]] = vector.shape_cast %[[ARG]] :
151153// CHECK-SAME: vector<1x4x4x1x1xi8> to vector<4x4xi8>
152154// CHECK: return %[[SHAPE_CAST]] : vector<4x4xi8>
153- func.func @transpose_shape_cast (%arg : vector <1 x4 x4 x1 x1 xi8 >) -> vector <4 x4 xi8 > {
155+ func.func @shape_cast_of_transpose (%arg : vector <1 x4 x4 x1 x1 xi8 >) -> vector <4 x4 xi8 > {
154156 %0 = vector.transpose %arg , [1 , 0 , 3 , 4 , 2 ]
155157 : vector <1 x4 x4 x1 x1 xi8 > to vector <4 x1 x1 x1 x4 xi8 >
156158 %1 = vector.shape_cast %0 : vector <4 x1 x1 x1 x4 xi8 > to vector <4 x4 xi8 >
@@ -159,18 +161,17 @@ func.func @transpose_shape_cast(%arg : vector<1x4x4x1x1xi8>) -> vector<4x4xi8> {
159161
160162// -----
161163
162- // Test of FoldTransposeShapeCast
163164// In this test, the mapping of non-unit dimensions (1 and 2) is as follows:
164165// 1 -> 2
165166// 2 -> 1
166167// As this is not increasing (2 > 1), this transpose is not order
167168// preserving and cannot be treated as a shape_cast.
168- // CHECK-LABEL: @negative_transpose_shape_cast
169+ // CHECK-LABEL: @negative_shape_cast_of_transpose
169170// CHECK-SAME: %[[ARG:.*]]: vector<1x4x4x1xi8>) -> vector<4x4xi8> {
170171// CHECK: %[[TRANSPOSE:.*]] = vector.transpose %[[ARG]]
171172// CHECK: %[[SHAPE_CAST:.*]] = vector.shape_cast %[[TRANSPOSE]]
172173// CHECK: return %[[SHAPE_CAST]] : vector<4x4xi8>
173- func.func @negative_transpose_shape_cast (%arg : vector <1 x4 x4 x1 xi8 >) -> vector <4 x4 xi8 > {
174+ func.func @negative_shape_cast_of_transpose (%arg : vector <1 x4 x4 x1 xi8 >) -> vector <4 x4 xi8 > {
174175 %0 = vector.transpose %arg , [0 , 2 , 1 , 3 ]
175176 : vector <1 x4 x4 x1 xi8 > to vector <1 x4 x4 x1 xi8 >
176177 %1 = vector.shape_cast %0 : vector <1 x4 x4 x1 xi8 > to vector <4 x4 xi8 >
@@ -179,42 +180,43 @@ func.func @negative_transpose_shape_cast(%arg : vector<1x4x4x1xi8>) -> vector<4x
179180
180181// -----
181182
182- // Test of FoldTransposeShapeCast
183183// Currently the conversion shape_cast(transpose) -> shape_cast is disabled for
184184// scalable vectors because of bad interaction with ConvertIllegalShapeCastOpsToTransposes
185- // CHECK-LABEL: @negative_transpose_shape_cast_scalable
185+ // CHECK-LABEL: @negative_shape_cast_of_transpose_scalable
186186// CHECK: vector.transpose
187187// CHECK: vector.shape_cast
188- func.func @negative_transpose_shape_cast_scalable (%arg : vector <[4 ]x1 xi8 >) -> vector <[4 ]xi8 > {
188+ func.func @negative_shape_cast_of_transpose_scalable (%arg : vector <[4 ]x1 xi8 >) -> vector <[4 ]xi8 > {
189189 %0 = vector.transpose %arg , [1 , 0 ] : vector <[4 ]x1 xi8 > to vector <1 x[4 ]xi8 >
190190 %1 = vector.shape_cast %0 : vector <1 x[4 ]xi8 > to vector <[4 ]xi8 >
191191 return %1 : vector <[4 ]xi8 >
192192}
193193
194194// -----
195195
196- // Test of shape_cast folding.
196+ /// +--------------------------------------------------------------------------
197+ /// Tests of FoldTransposeShapeCast: transpose(shape_cast) -> shape_cast
198+ /// +--------------------------------------------------------------------------
199+
197200// The conversion transpose(shape_cast) -> shape_cast is not disabled for scalable
198201// vectors.
199- // CHECK-LABEL: @shape_cast_transpose_scalable
202+ // CHECK-LABEL: @transpose_of_shape_cast_scalable
200203// CHECK: vector.shape_cast
201204// CHECK-SAME: vector<[4]xi8> to vector<[4]x1xi8>
202- func.func @shape_cast_transpose_scalable (%arg : vector <[4 ]xi8 >) -> vector <[4 ]x1 xi8 > {
205+ func.func @transpose_of_shape_cast_scalable (%arg : vector <[4 ]xi8 >) -> vector <[4 ]x1 xi8 > {
203206 %0 = vector.shape_cast %arg : vector <[4 ]xi8 > to vector <1 x[4 ]xi8 >
204207 %1 = vector.transpose %0 , [1 , 0 ] : vector <1 x[4 ]xi8 > to vector <[4 ]x1 xi8 >
205208 return %1 : vector <[4 ]x1 xi8 >
206209}
207210
208211// -----
209212
210- // Test of shape_cast folding.
211213// A transpose that is 'order preserving' can be treated like a shape_cast.
212- // CHECK-LABEL: @shape_cast_transpose
214+ // CHECK-LABEL: @transpose_of_shape_cast
213215// CHECK-SAME: %[[ARG:.*]]: vector<2x3x1x1xi8>) -> vector<6x1x1xi8> {
214216// CHECK: %[[SHAPE_CAST:.*]] = vector.shape_cast %[[ARG]] :
215217// CHECK-SAME: vector<2x3x1x1xi8> to vector<6x1x1xi8>
216218// CHECK: return %[[SHAPE_CAST]] : vector<6x1x1xi8>
217- func.func @shape_cast_transpose (%arg : vector <2 x3 x1 x1 xi8 >) -> vector <6 x1 x1 xi8 > {
219+ func.func @transpose_of_shape_cast (%arg : vector <2 x3 x1 x1 xi8 >) -> vector <6 x1 x1 xi8 > {
218220 %0 = vector.shape_cast %arg : vector <2 x3 x1 x1 xi8 > to vector <6 x1 x1 xi8 >
219221 %1 = vector.transpose %0 , [0 , 2 , 1 ]
220222 : vector <6 x1 x1 xi8 > to vector <6 x1 x1 xi8 >
@@ -223,12 +225,11 @@ func.func @shape_cast_transpose(%arg : vector<2x3x1x1xi8>) -> vector<6x1x1xi8>
223225
224226// -----
225227
226- // Test of shape_cast folding.
227228// Scalable dimensions should be treated as non-unit dimensions.
228- // CHECK-LABEL: @shape_cast_transpose_scalable
229+ // CHECK-LABEL: @transpose_of_shape_cast_scalable
229230// CHECK: vector.shape_cast
230231// CHECK: vector.transpose
231- func.func @shape_cast_transpose_scalable_unit (%arg : vector <[1 ]x4 x1 xi8 >) -> vector <4 x[1 ]xi8 > {
232+ func.func @transpose_of_shape_cast_scalable_unit (%arg : vector <[1 ]x4 x1 xi8 >) -> vector <4 x[1 ]xi8 > {
232233 %0 = vector.shape_cast %arg : vector <[1 ]x4 x1 xi8 > to vector <[1 ]x4 xi8 >
233234 %1 = vector.transpose %0 , [1 , 0 ] : vector <[1 ]x4 xi8 > to vector <4 x[1 ]xi8 >
234235 return %1 : vector <4 x[1 ]xi8 >
@@ -237,12 +238,12 @@ func.func @shape_cast_transpose_scalable_unit(%arg : vector<[1]x4x1xi8>) -> vect
237238// -----
238239
239240// Test of shape_cast (not) folding.
240- // CHECK-LABEL: @negative_shape_cast_transpose
241+ // CHECK-LABEL: @negative_transpose_of_shape_cast
241242// CHECK-SAME: %[[ARG:.*]]: vector<6xi8>) -> vector<2x3xi8> {
242243// CHECK: %[[SHAPE_CAST:.*]] = vector.shape_cast %[[ARG]] :
243244// CHECK: %[[TRANSPOSE:.*]] = vector.transpose %[[SHAPE_CAST]]
244245// CHECK: return %[[TRANSPOSE]] : vector<2x3xi8>
245- func.func @negative_shape_cast_transpose (%arg : vector <6 xi8 >) -> vector <2 x3 xi8 > {
246+ func.func @negative_transpose_of_shape_cast (%arg : vector <6 xi8 >) -> vector <2 x3 xi8 > {
246247 %0 = vector.shape_cast %arg : vector <6 xi8 > to vector <3 x2 xi8 >
247248 %1 = vector.transpose %0 , [1 , 0 ] : vector <3 x2 xi8 > to vector <2 x3 xi8 >
248249 return %1 : vector <2 x3 xi8 >
0 commit comments