@@ -812,8 +812,8 @@ namespace {
812812/// Main data required for vectorization of instructions.
813813class InstructionsState {
814814 /// The main/alternate instruction. MainOp is also VL0.
815- Instruction *MainOp = nullptr ;
816- Instruction *AltOp = nullptr ;
815+ Instruction *MainOp;
816+ Instruction *AltOp;
817817
818818public:
819819 Instruction *getMainOp() const {
@@ -844,10 +844,9 @@ class InstructionsState {
844844
845845 explicit operator bool() const { return valid(); }
846846
847- InstructionsState() = delete;
847+ InstructionsState() : InstructionsState(nullptr, nullptr) {}
848848 InstructionsState(Instruction *MainOp, Instruction *AltOp)
849849 : MainOp(MainOp), AltOp(AltOp) {}
850- static InstructionsState invalid() { return {nullptr, nullptr}; }
851850};
852851
853852} // end anonymous namespace
@@ -909,17 +908,17 @@ static InstructionsState getSameOpcode(ArrayRef<Value *> VL,
909908 const TargetLibraryInfo &TLI) {
910909 // Make sure these are all Instructions.
911910 if (!all_of(VL, IsaPred<Instruction, PoisonValue>))
912- return InstructionsState::invalid ();
911+ return InstructionsState();
913912
914913 auto *It = find_if(VL, IsaPred<Instruction>);
915914 if (It == VL.end())
916- return InstructionsState::invalid ();
915+ return InstructionsState();
917916
918917 Value *V = *It;
919918 unsigned InstCnt = std::count_if(It, VL.end(), IsaPred<Instruction>);
920919 if ((VL.size() > 2 && !isa<PHINode>(V) && InstCnt < VL.size() / 2) ||
921920 (VL.size() == 2 && InstCnt < 2))
922- return InstructionsState::invalid ();
921+ return InstructionsState();
923922
924923 bool IsCastOp = isa<CastInst>(V);
925924 bool IsBinOp = isa<BinaryOperator>(V);
@@ -962,7 +961,7 @@ static InstructionsState getSameOpcode(ArrayRef<Value *> VL,
962961 BaseID = getVectorIntrinsicIDForCall(CallBase, &TLI);
963962 BaseMappings = VFDatabase(*CallBase).getMappings(*CallBase);
964963 if (!isTriviallyVectorizable(BaseID) && BaseMappings.empty())
965- return InstructionsState::invalid ();
964+ return InstructionsState();
966965 }
967966 bool AnyPoison = InstCnt != VL.size();
968967 for (int Cnt = 0, E = VL.size(); Cnt < E; Cnt++) {
@@ -974,7 +973,7 @@ static InstructionsState getSameOpcode(ArrayRef<Value *> VL,
974973 // TODO: do some smart analysis of the CallInsts to exclude divide-like
975974 // intrinsics/functions only.
976975 if (AnyPoison && (I->isIntDivRem() || I->isFPDivRem() || isa<CallInst>(I)))
977- return InstructionsState::invalid ();
976+ return InstructionsState();
978977 unsigned InstOpcode = I->getOpcode();
979978 if (IsBinOp && isa<BinaryOperator>(I)) {
980979 if (InstOpcode == Opcode || InstOpcode == AltOpcode)
@@ -1046,28 +1045,28 @@ static InstructionsState getSameOpcode(ArrayRef<Value *> VL,
10461045 if (auto *Gep = dyn_cast<GetElementPtrInst>(I)) {
10471046 if (Gep->getNumOperands() != 2 ||
10481047 Gep->getOperand(0)->getType() != IBase->getOperand(0)->getType())
1049- return InstructionsState::invalid ();
1048+ return InstructionsState();
10501049 } else if (auto *EI = dyn_cast<ExtractElementInst>(I)) {
10511050 if (!isVectorLikeInstWithConstOps(EI))
1052- return InstructionsState::invalid ();
1051+ return InstructionsState();
10531052 } else if (auto *LI = dyn_cast<LoadInst>(I)) {
10541053 auto *BaseLI = cast<LoadInst>(IBase);
10551054 if (!LI->isSimple() || !BaseLI->isSimple())
1056- return InstructionsState::invalid ();
1055+ return InstructionsState();
10571056 } else if (auto *Call = dyn_cast<CallInst>(I)) {
10581057 auto *CallBase = cast<CallInst>(IBase);
10591058 if (Call->getCalledFunction() != CallBase->getCalledFunction())
1060- return InstructionsState::invalid ();
1059+ return InstructionsState();
10611060 if (Call->hasOperandBundles() &&
10621061 (!CallBase->hasOperandBundles() ||
10631062 !std::equal(Call->op_begin() + Call->getBundleOperandsStartIndex(),
10641063 Call->op_begin() + Call->getBundleOperandsEndIndex(),
10651064 CallBase->op_begin() +
10661065 CallBase->getBundleOperandsStartIndex())))
1067- return InstructionsState::invalid ();
1066+ return InstructionsState();
10681067 Intrinsic::ID ID = getVectorIntrinsicIDForCall(Call, &TLI);
10691068 if (ID != BaseID)
1070- return InstructionsState::invalid ();
1069+ return InstructionsState();
10711070 if (!ID) {
10721071 SmallVector<VFInfo> Mappings = VFDatabase(*Call).getMappings(*Call);
10731072 if (Mappings.size() != BaseMappings.size() ||
@@ -1077,12 +1076,12 @@ static InstructionsState getSameOpcode(ArrayRef<Value *> VL,
10771076 Mappings.front().Shape.VF != BaseMappings.front().Shape.VF ||
10781077 Mappings.front().Shape.Parameters !=
10791078 BaseMappings.front().Shape.Parameters)
1080- return InstructionsState::invalid ();
1079+ return InstructionsState();
10811080 }
10821081 }
10831082 continue;
10841083 }
1085- return InstructionsState::invalid ();
1084+ return InstructionsState();
10861085 }
10871086
10881087 return InstructionsState(cast<Instruction>(V),
0 commit comments