@@ -916,6 +916,7 @@ static InstructionsState getSameOpcode(ArrayRef<Value *> VL,
916916 return InstructionsState::invalid();
917917
918918 Value *V = *It;
919+ Instruction *MainOp = cast<Instruction>(V);
919920 unsigned InstCnt = std::count_if(It, VL.end(), IsaPred<Instruction>);
920921 if ((VL.size() > 2 && !isa<PHINode>(V) && InstCnt < VL.size() / 2) ||
921922 (VL.size() == 2 && InstCnt < 2))
@@ -955,10 +956,9 @@ static InstructionsState getSameOpcode(ArrayRef<Value *> VL,
955956 }();
956957 // Check for one alternate opcode from another BinaryOperator.
957958 // TODO - generalize to support all operators (types, calls etc.).
958- auto *IBase = cast<Instruction>(V);
959959 Intrinsic::ID BaseID = 0;
960960 SmallVector<VFInfo> BaseMappings;
961- if (auto *CallBase = dyn_cast<CallInst>(IBase )) {
961+ if (auto *CallBase = dyn_cast<CallInst>(MainOp )) {
962962 BaseID = getVectorIntrinsicIDForCall(CallBase, &TLI);
963963 BaseMappings = VFDatabase(*CallBase).getMappings(*CallBase);
964964 if (!isTriviallyVectorizable(BaseID) && BaseMappings.empty())
@@ -986,7 +986,7 @@ static InstructionsState getSameOpcode(ArrayRef<Value *> VL,
986986 continue;
987987 }
988988 } else if (IsCastOp && isa<CastInst>(I)) {
989- Value *Op0 = IBase ->getOperand(0);
989+ Value *Op0 = MainOp ->getOperand(0);
990990 Type *Ty0 = Op0->getType();
991991 Value *Op1 = I->getOperand(0);
992992 Type *Ty1 = Op1->getType();
@@ -1045,17 +1045,17 @@ static InstructionsState getSameOpcode(ArrayRef<Value *> VL,
10451045 "CastInst.");
10461046 if (auto *Gep = dyn_cast<GetElementPtrInst>(I)) {
10471047 if (Gep->getNumOperands() != 2 ||
1048- Gep->getOperand(0)->getType() != IBase ->getOperand(0)->getType())
1048+ Gep->getOperand(0)->getType() != MainOp ->getOperand(0)->getType())
10491049 return InstructionsState::invalid();
10501050 } else if (auto *EI = dyn_cast<ExtractElementInst>(I)) {
10511051 if (!isVectorLikeInstWithConstOps(EI))
10521052 return InstructionsState::invalid();
10531053 } else if (auto *LI = dyn_cast<LoadInst>(I)) {
1054- auto *BaseLI = cast<LoadInst>(IBase );
1054+ auto *BaseLI = cast<LoadInst>(MainOp );
10551055 if (!LI->isSimple() || !BaseLI->isSimple())
10561056 return InstructionsState::invalid();
10571057 } else if (auto *Call = dyn_cast<CallInst>(I)) {
1058- auto *CallBase = cast<CallInst>(IBase );
1058+ auto *CallBase = cast<CallInst>(MainOp );
10591059 if (Call->getCalledFunction() != CallBase->getCalledFunction())
10601060 return InstructionsState::invalid();
10611061 if (Call->hasOperandBundles() &&
0 commit comments