@@ -1106,8 +1106,8 @@ struct ConvertVectorMaskedLoad final
1106
1106
// / * vector<4xi4> -> i8 - yes (N = 2)
1107
1107
// / * vector<3xi4> -> i8 - no (N would have to be 1.5)
1108
1108
// / * vector<3xi2> -> i16 - no (N would have to be 0.5)
1109
- static bool isSubByteVecFittable (VectorType subByteVecTy,
1110
- Type multiByteScalarTy) {
1109
+ static bool fitsInMultiByteContainerTy (VectorType subByteVecTy,
1110
+ Type multiByteScalarTy) {
1111
1111
assert ((isa<IntegerType, FloatType>(multiByteScalarTy)) && " Not scalar!" );
1112
1112
1113
1113
int subByteBits = subByteVecTy.getElementType ().getIntOrFloatBitWidth ();
@@ -1160,7 +1160,7 @@ struct ConvertVectorTransferRead final
1160
1160
1161
1161
// Note, per-element-alignment was already verified above.
1162
1162
bool isFullyAligned =
1163
- isSubByteVecFittable (op.getVectorType (), containerElemTy);
1163
+ fitsInMultiByteContainerTy (op.getVectorType (), containerElemTy);
1164
1164
1165
1165
auto newPadding = rewriter.create <arith::ExtUIOp>(loc, containerElemTy,
1166
1166
adaptor.getPadding ());
@@ -1496,38 +1496,31 @@ static LogicalResult alignedConversionPrecondition(PatternRewriter &rewriter,
1496
1496
VectorType subByteVecTy,
1497
1497
Type containerTy,
1498
1498
Operation *op) {
1499
+ assert (containerTy.isIntOrFloat () &&
1500
+ " container element type is not a scalar" );
1501
+
1499
1502
// TODO: This is validating the inputs rather than checking the conditions
1500
1503
// documented above. Replace with an assert.
1501
1504
if (!subByteVecTy)
1502
1505
return rewriter.notifyMatchFailure (op, " not a vector!" );
1503
1506
1504
- // TODO: This is validating the inputs rather than checking the conditions
1505
- // documented above. Replace with an assert.
1506
- if (!containerTy.isIntOrFloat ())
1507
- return rewriter.notifyMatchFailure (op, " not a scalar!" );
1508
-
1509
1507
unsigned subByteBits = subByteVecTy.getElementTypeBitWidth ();
1510
1508
unsigned multiByteBits = containerTy.getIntOrFloatBitWidth ();
1511
1509
1512
1510
// Enforced by the common pre-conditions.
1513
1511
assert (multiByteBits % 8 == 0 && " Not a multi-byte scalar type!" );
1514
1512
1515
- // TODO: Remove this condition - the assert above (and
1516
- // commonConversionPrecondtion) takes care of that.
1517
- if (multiByteBits < 8 )
1518
- return rewriter.notifyMatchFailure (op, " not a multi-byte scalar type!" );
1519
-
1520
1513
// TODO: Add support other widths (when/if needed)
1521
1514
if (subByteBits != 2 && subByteBits != 4 )
1522
1515
return rewriter.notifyMatchFailure (
1523
1516
op, " only 2-bit and 4-bit sub-byte type is supported at this moment" );
1524
1517
1525
- // Condition 1.
1518
+ // Condition 1 ("per-element" alignment)
1526
1519
if (multiByteBits % subByteBits != 0 )
1527
1520
return rewriter.notifyMatchFailure (op, " unalagined element types" );
1528
1521
1529
- // Condition 2.
1530
- if (!isSubByteVecFittable (subByteVecTy, containerTy))
1522
+ // Condition 2 ("full" alignment)
1523
+ if (!fitsInMultiByteContainerTy (subByteVecTy, containerTy))
1531
1524
return rewriter.notifyMatchFailure (
1532
1525
op, " not possible to fit this sub-byte vector type into a vector of "
1533
1526
" the given multi-byte type" );
@@ -1967,9 +1960,9 @@ struct RewriteAlignedSubByteIntExt : OpRewritePattern<ConversionOpType> {
1967
1960
return failure ();
1968
1961
1969
1962
// Check general alignment preconditions.
1970
- Type containerType = rewriter. getI8Type ();
1971
- if ( failed ( alignedConversionPrecondition ( rewriter, srcVecType,
1972
- containerType , conversionOp)))
1963
+ if ( failed ( alignedConversionPrecondition (
1964
+ rewriter, srcVecType,
1965
+ /* containerTy= */ rewriter. getI8Type () , conversionOp)))
1973
1966
return failure ();
1974
1967
1975
1968
// Perform the rewrite.
@@ -2033,9 +2026,9 @@ struct RewriteAlignedSubByteIntTrunc : OpRewritePattern<arith::TruncIOp> {
2033
2026
2034
2027
// Check general alignment preconditions. We invert the src/dst type order
2035
2028
// to reuse the existing precondition logic.
2036
- Type containerType = rewriter. getI8Type ();
2037
- if ( failed ( alignedConversionPrecondition ( rewriter, dstVecType,
2038
- containerType , truncOp)))
2029
+ if ( failed ( alignedConversionPrecondition (
2030
+ rewriter, dstVecType,
2031
+ /* containerTy= */ rewriter. getI8Type () , truncOp)))
2039
2032
return failure ();
2040
2033
2041
2034
// Create a new iX -> i8 truncation op.
0 commit comments