@@ -700,9 +700,9 @@ bool ScalarizerVisitor::isTriviallyScalarizable(Intrinsic::ID ID) {
700700// / element if possible for the intrinsic.
701701bool ScalarizerVisitor::splitCall (CallInst &CI) {
702702 Type *CallType = CI.getType ();
703- bool AreAllVectors = isStructOfMatchingFixedVectors (CallType);
703+ bool AreAllMatchingVectors = isStructOfMatchingFixedVectors (CallType);
704704 std::optional<VectorSplit> VS;
705- if (AreAllVectors )
705+ if (AreAllMatchingVectors )
706706 VS = getVectorSplit (CallType->getContainedType (0 ));
707707 else
708708 VS = getVectorSplit (CallType);
@@ -730,12 +730,17 @@ bool ScalarizerVisitor::splitCall(CallInst &CI) {
730730 if (isVectorIntrinsicWithOverloadTypeAtArg (ID, -1 ))
731731 Tys.push_back (VS->SplitTy );
732732
733- if (AreAllVectors ) {
733+ if (AreAllMatchingVectors ) {
734734 Type *PrevType = CallType->getContainedType (0 );
735735 for (unsigned I = 1 ; I < CallType->getNumContainedTypes (); I++) {
736736 Type *CurrType = cast<FixedVectorType>(CallType->getContainedType (I));
737737 if (PrevType != CurrType) {
738738 std::optional<VectorSplit> CurrVS = getVectorSplit (CurrType);
739+ // This case does not seem to happen, but it is possible for
740+ // VectorSplit.NumPacked >= NumElems. If that happens a VectorSplit
741+ // is not returned and we will bailout of handling this call.
742+ if (!CurrVS)
743+ return false ;
739744 Tys.push_back (CurrVS->SplitTy );
740745 PrevType = CurrType;
741746 }
0 commit comments