@@ -197,16 +197,17 @@ struct VectorLayout {
197197 uint64_t SplitSize = 0 ;
198198};
199199
200- static bool isStructAllVectors (Type *Ty) {
200+ static bool isStructOfMatchingFixedVectors (Type *Ty) {
201201 if (!isa<StructType>(Ty))
202202 return false ;
203- if (Ty->getNumContainedTypes () < 1 )
203+ unsigned StructSize = Ty->getNumContainedTypes ();
204+ if (StructSize < 1 )
204205 return false ;
205206 FixedVectorType *VecTy = dyn_cast<FixedVectorType>(Ty->getContainedType (0 ));
206207 if (!VecTy)
207208 return false ;
208209 unsigned VecSize = VecTy->getNumElements ();
209- for (unsigned I = 1 ; I < Ty-> getNumContainedTypes () ; I++) {
210+ for (unsigned I = 1 ; I < StructSize ; I++) {
210211 VecTy = dyn_cast<FixedVectorType>(Ty->getContainedType (I));
211212 if (!VecTy || VecSize != VecTy->getNumElements ())
212213 return false ;
@@ -685,7 +686,8 @@ bool ScalarizerVisitor::splitBinary(Instruction &I, const Splitter &Split) {
685686bool ScalarizerVisitor::isTriviallyScalarizable (Intrinsic::ID ID) {
686687 if (isTriviallyVectorizable (ID))
687688 return true ;
688- // TODO: investigate vectorizable frexp
689+ // TODO: Move frexp to isTriviallyVectorizable.
690+ // https://github.com/llvm/llvm-project/issues/112408
689691 switch (ID) {
690692 case Intrinsic::frexp:
691693 return true ;
@@ -698,7 +700,7 @@ bool ScalarizerVisitor::isTriviallyScalarizable(Intrinsic::ID ID) {
698700// / element if possible for the intrinsic.
699701bool ScalarizerVisitor::splitCall (CallInst &CI) {
700702 Type *CallType = CI.getType ();
701- bool AreAllVectors = isStructAllVectors (CallType);
703+ bool AreAllVectors = isStructOfMatchingFixedVectors (CallType);
702704 std::optional<VectorSplit> VS;
703705 if (AreAllVectors)
704706 VS = getVectorSplit (CallType->getContainedType (0 ));
@@ -730,7 +732,6 @@ bool ScalarizerVisitor::splitCall(CallInst &CI) {
730732
731733 if (AreAllVectors) {
732734 Type *PrevType = CallType->getContainedType (0 );
733- Type *CallType = CI.getType ();
734735 for (unsigned I = 1 ; I < CallType->getNumContainedTypes (); I++) {
735736 Type *CurrType = cast<FixedVectorType>(CallType->getContainedType (I));
736737 if (PrevType != CurrType) {
@@ -1075,7 +1076,7 @@ bool ScalarizerVisitor::visitExtractValueInst(ExtractValueInst &EVI) {
10751076 Value *Op = EVI.getOperand (0 );
10761077 Type *OpTy = Op->getType ();
10771078 ValueVector Res;
1078- if (!isStructAllVectors (OpTy))
1079+ if (!isStructOfMatchingFixedVectors (OpTy))
10791080 return false ;
10801081 Type *VecType = cast<FixedVectorType>(OpTy->getContainedType (0 ));
10811082 std::optional<VectorSplit> VS = getVectorSplit (VecType);
@@ -1262,7 +1263,7 @@ bool ScalarizerVisitor::finish() {
12621263 if (!Op->use_empty ()) {
12631264 // The value is still needed, so recreate it using a series of
12641265 // insertelements and/or shufflevectors.
1265- Value *Res = nullptr ;
1266+ Value *Res;
12661267 if (auto *Ty = dyn_cast<FixedVectorType>(Op->getType ())) {
12671268 BasicBlock *BB = Op->getParent ();
12681269 IRBuilder<> Builder (Op);
@@ -1287,7 +1288,7 @@ bool ScalarizerVisitor::finish() {
12871288 for (unsigned I = 0 ; I < NumOfStructElements; ++I) {
12881289 for (auto *CVelem : CV) {
12891290 Value *Elem = Builder.CreateExtractValue (
1290- CVelem, I, Op->getName () + " .elem" + std::to_string (I));
1291+ CVelem, I, Op->getName () + " .elem" + Twine (I));
12911292 ElemCV[I].push_back (Elem);
12921293 }
12931294 }
0 commit comments