@@ -944,42 +944,45 @@ static unsigned getVectorTypeBreakdownMVT(MVT VT, MVT &IntermediateVT,
944
944
MVT &RegisterVT,
945
945
TargetLoweringBase *TLI) {
946
946
// Figure out the right, legal destination reg to copy into.
947
- unsigned NumElts = VT.getVectorNumElements ();
947
+ ElementCount EC = VT.getVectorElementCount ();
948
948
MVT EltTy = VT.getVectorElementType ();
949
949
950
950
unsigned NumVectorRegs = 1 ;
951
951
952
- // FIXME: We don't support non-power-of-2-sized vectors for now. Ideally we
953
- // could break down into LHS/RHS like LegalizeDAG does.
954
- if (!isPowerOf2_32 (NumElts)) {
955
- NumVectorRegs = NumElts;
956
- NumElts = 1 ;
952
+ // FIXME: We don't support non-power-of-2-sized vectors for now.
953
+ // Ideally we could break down into LHS/RHS like LegalizeDAG does.
954
+ if (!isPowerOf2_32 (EC.Min )) {
955
+ // Split EC to unit size (scalable property is preserved).
956
+ NumVectorRegs = EC.Min ;
957
+ EC = EC / NumVectorRegs;
957
958
}
958
959
959
- // Divide the input until we get to a supported size. This will always
960
- // end with a scalar if the target doesn't support vectors.
961
- while (NumElts > 1 && !TLI->isTypeLegal (MVT::getVectorVT (EltTy, NumElts))) {
962
- NumElts >>= 1 ;
960
+ // Divide the input until we get to a supported size. This will
961
+ // always end up with an EC that represent a scalar or a scalable
962
+ // scalar.
963
+ while (EC.Min > 1 && !TLI->isTypeLegal (MVT::getVectorVT (EltTy, EC))) {
964
+ EC.Min >>= 1 ;
963
965
NumVectorRegs <<= 1 ;
964
966
}
965
967
966
968
NumIntermediates = NumVectorRegs;
967
969
968
- MVT NewVT = MVT::getVectorVT (EltTy, NumElts );
970
+ MVT NewVT = MVT::getVectorVT (EltTy, EC );
969
971
if (!TLI->isTypeLegal (NewVT))
970
972
NewVT = EltTy;
971
973
IntermediateVT = NewVT;
972
974
973
- unsigned NewVTSize = NewVT.getSizeInBits ();
975
+ unsigned LaneSizeInBits = NewVT.getScalarSizeInBits (). getFixedSize ();
974
976
975
977
// Convert sizes such as i33 to i64.
976
- if (!isPowerOf2_32 (NewVTSize ))
977
- NewVTSize = NextPowerOf2 (NewVTSize );
978
+ if (!isPowerOf2_32 (LaneSizeInBits ))
979
+ LaneSizeInBits = NextPowerOf2 (LaneSizeInBits );
978
980
979
981
MVT DestVT = TLI->getRegisterType (NewVT);
980
982
RegisterVT = DestVT;
981
983
if (EVT (DestVT).bitsLT (NewVT)) // Value is expanded, e.g. i64 -> i16.
982
- return NumVectorRegs*(NewVTSize/DestVT.getSizeInBits ());
984
+ return NumVectorRegs *
985
+ (LaneSizeInBits / DestVT.getScalarSizeInBits ().getFixedSize ());
983
986
984
987
// Otherwise, promotion or legal types use the same number of registers as
985
988
// the vector decimated to the appropriate level.
0 commit comments