@@ -915,19 +915,18 @@ static InstructionsState getSameOpcode(ArrayRef<Value *> VL,
915915 if (It == VL.end())
916916 return InstructionsState::invalid();
917917
918- Value *V = *It;
919- Instruction *MainOp = cast<Instruction>(V);
918+ Instruction *MainOp = cast<Instruction>(*It);
920919 unsigned InstCnt = std::count_if(It, VL.end(), IsaPred<Instruction>);
921- if ((VL.size() > 2 && !isa<PHINode>(V ) && InstCnt < VL.size() / 2) ||
920+ if ((VL.size() > 2 && !isa<PHINode>(MainOp ) && InstCnt < VL.size() / 2) ||
922921 (VL.size() == 2 && InstCnt < 2))
923922 return InstructionsState::invalid();
924923
925- bool IsCastOp = isa<CastInst>(V );
926- bool IsBinOp = isa<BinaryOperator>(V );
927- bool IsCmpOp = isa<CmpInst>(V );
928- CmpInst::Predicate BasePred =
929- IsCmpOp ? cast<CmpInst>(V)->getPredicate() : CmpInst::BAD_ICMP_PREDICATE;
930- unsigned Opcode = cast<Instruction>(V) ->getOpcode();
924+ bool IsCastOp = isa<CastInst>(MainOp );
925+ bool IsBinOp = isa<BinaryOperator>(MainOp );
926+ bool IsCmpOp = isa<CmpInst>(MainOp );
927+ CmpInst::Predicate BasePred = IsCmpOp ? cast<CmpInst>(MainOp)->getPredicate()
928+ : CmpInst::BAD_ICMP_PREDICATE;
929+ unsigned Opcode = MainOp ->getOpcode();
931930 unsigned AltOpcode = Opcode;
932931 unsigned AltIndex = std::distance(VL.begin(), It);
933932
@@ -1003,7 +1002,7 @@ static InstructionsState getSameOpcode(ArrayRef<Value *> VL,
10031002 }
10041003 }
10051004 } else if (auto *Inst = dyn_cast<CmpInst>(VL[Cnt]); Inst && IsCmpOp) {
1006- auto *BaseInst = cast<CmpInst>(V );
1005+ auto *BaseInst = cast<CmpInst>(MainOp );
10071006 Type *Ty0 = BaseInst->getOperand(0)->getType();
10081007 Type *Ty1 = Inst->getOperand(0)->getType();
10091008 if (Ty0 == Ty1) {
@@ -1085,8 +1084,7 @@ static InstructionsState getSameOpcode(ArrayRef<Value *> VL,
10851084 return InstructionsState::invalid();
10861085 }
10871086
1088- return InstructionsState(cast<Instruction>(V),
1089- cast<Instruction>(VL[AltIndex]));
1087+ return InstructionsState(MainOp, cast<Instruction>(VL[AltIndex]));
10901088}
10911089
10921090/// \returns true if all of the values in \p VL have the same type or false
0 commit comments