@@ -197,16 +197,17 @@ struct VectorLayout {
197
197
uint64_t SplitSize = 0 ;
198
198
};
199
199
200
- static bool isStructAllVectors (Type *Ty) {
200
+ static bool isStructOfMatchingFixedVectors (Type *Ty) {
201
201
if (!isa<StructType>(Ty))
202
202
return false ;
203
- if (Ty->getNumContainedTypes () < 1 )
203
+ unsigned StructSize = Ty->getNumContainedTypes ();
204
+ if (StructSize < 1 )
204
205
return false ;
205
206
FixedVectorType *VecTy = dyn_cast<FixedVectorType>(Ty->getContainedType (0 ));
206
207
if (!VecTy)
207
208
return false ;
208
209
unsigned VecSize = VecTy->getNumElements ();
209
- for (unsigned I = 1 ; I < Ty-> getNumContainedTypes () ; I++) {
210
+ for (unsigned I = 1 ; I < StructSize ; I++) {
210
211
VecTy = dyn_cast<FixedVectorType>(Ty->getContainedType (I));
211
212
if (!VecTy || VecSize != VecTy->getNumElements ())
212
213
return false ;
@@ -685,7 +686,8 @@ bool ScalarizerVisitor::splitBinary(Instruction &I, const Splitter &Split) {
685
686
bool ScalarizerVisitor::isTriviallyScalarizable (Intrinsic::ID ID) {
686
687
if (isTriviallyVectorizable (ID))
687
688
return true ;
688
- // TODO: investigate vectorizable frexp
689
+ // TODO: Move frexp to isTriviallyVectorizable.
690
+ // https://github.com/llvm/llvm-project/issues/112408
689
691
switch (ID) {
690
692
case Intrinsic::frexp:
691
693
return true ;
@@ -698,7 +700,7 @@ bool ScalarizerVisitor::isTriviallyScalarizable(Intrinsic::ID ID) {
698
700
// / element if possible for the intrinsic.
699
701
bool ScalarizerVisitor::splitCall (CallInst &CI) {
700
702
Type *CallType = CI.getType ();
701
- bool AreAllVectors = isStructAllVectors (CallType);
703
+ bool AreAllVectors = isStructOfMatchingFixedVectors (CallType);
702
704
std::optional<VectorSplit> VS;
703
705
if (AreAllVectors)
704
706
VS = getVectorSplit (CallType->getContainedType (0 ));
@@ -730,7 +732,6 @@ bool ScalarizerVisitor::splitCall(CallInst &CI) {
730
732
731
733
if (AreAllVectors) {
732
734
Type *PrevType = CallType->getContainedType (0 );
733
- Type *CallType = CI.getType ();
734
735
for (unsigned I = 1 ; I < CallType->getNumContainedTypes (); I++) {
735
736
Type *CurrType = cast<FixedVectorType>(CallType->getContainedType (I));
736
737
if (PrevType != CurrType) {
@@ -1075,7 +1076,7 @@ bool ScalarizerVisitor::visitExtractValueInst(ExtractValueInst &EVI) {
1075
1076
Value *Op = EVI.getOperand (0 );
1076
1077
Type *OpTy = Op->getType ();
1077
1078
ValueVector Res;
1078
- if (!isStructAllVectors (OpTy))
1079
+ if (!isStructOfMatchingFixedVectors (OpTy))
1079
1080
return false ;
1080
1081
Type *VecType = cast<FixedVectorType>(OpTy->getContainedType (0 ));
1081
1082
std::optional<VectorSplit> VS = getVectorSplit (VecType);
@@ -1262,7 +1263,7 @@ bool ScalarizerVisitor::finish() {
1262
1263
if (!Op->use_empty ()) {
1263
1264
// The value is still needed, so recreate it using a series of
1264
1265
// insertelements and/or shufflevectors.
1265
- Value *Res = nullptr ;
1266
+ Value *Res;
1266
1267
if (auto *Ty = dyn_cast<FixedVectorType>(Op->getType ())) {
1267
1268
BasicBlock *BB = Op->getParent ();
1268
1269
IRBuilder<> Builder (Op);
@@ -1287,7 +1288,7 @@ bool ScalarizerVisitor::finish() {
1287
1288
for (unsigned I = 0 ; I < NumOfStructElements; ++I) {
1288
1289
for (auto *CVelem : CV) {
1289
1290
Value *Elem = Builder.CreateExtractValue (
1290
- CVelem, I, Op->getName () + " .elem" + std::to_string (I));
1291
+ CVelem, I, Op->getName () + " .elem" + Twine (I));
1291
1292
ElemCV[I].push_back (Elem);
1292
1293
}
1293
1294
}
0 commit comments