@@ -2424,7 +2424,7 @@ class BoUpSLP {
24242424
24252425 /// Return information about the vector formed for the specified index
24262426 /// of a vector of (the same) instruction.
2427- TargetTransformInfo::OperandValueInfo getOperandInfo(ArrayRef<Value *> VL ,
2427+ TargetTransformInfo::OperandValueInfo getOperandInfo(const TreeEntry &E ,
24282428 unsigned OpIdx);
24292429
24302430 /// \returns the cost of the vectorizable entry.
@@ -6521,52 +6521,29 @@ static bool isAlternateInstruction(const Instruction *I,
65216521 return I->getOpcode() == AltOp->getOpcode();
65226522}
65236523
6524- TTI::OperandValueInfo BoUpSLP::getOperandInfo(ArrayRef<Value *> VL ,
6524+ TTI::OperandValueInfo BoUpSLP::getOperandInfo(const TreeEntry &E ,
65256525 unsigned OpIdx) {
6526+ ArrayRef<Value*> VL = E.getOperand(OpIdx);
65266527 assert(!VL.empty());
6527- const auto *I0 = cast<Instruction>(*find_if(VL, Instruction::classof));
6528- const auto *Op0 = I0->getOperand(OpIdx);
6528+ const auto *Op0 = VL.front();
65296529
6530- const bool IsConstant = all_of(VL, [& ](Value *V) {
6530+ const bool IsConstant = all_of(VL, [](Value *V) {
65316531 // TODO: We should allow undef elements here
6532- const auto *I = dyn_cast<Instruction>(V);
6533- if (!I)
6534- return true;
6535- auto *Op = I->getOperand(OpIdx);
6536- return isConstant(Op) && !isa<UndefValue>(Op);
6532+ return isConstant(V) && !isa<UndefValue>(V);
65376533 });
6538- const bool IsUniform = all_of(VL, [& ](Value *V) {
6534+ const bool IsUniform = all_of(VL, [= ](Value *V) {
65396535 // TODO: We should allow undef elements here
6540- const auto *I = dyn_cast<Instruction>(V);
6541- if (!I)
6542- return false;
6543- return I->getOperand(OpIdx) == Op0;
6536+ return V == Op0;
65446537 });
6545- const bool IsPowerOfTwo = all_of(VL, [& ](Value *V) {
6538+ const bool IsPowerOfTwo = all_of(VL, [](Value *V) {
65466539 // TODO: We should allow undef elements here
6547- const auto *I = dyn_cast<Instruction>(V);
6548- if (!I) {
6549- assert((isa<UndefValue>(V) ||
6550- I0->getOpcode() == Instruction::GetElementPtr) &&
6551- "Expected undef or GEP.");
6552- return true;
6553- }
6554- auto *Op = I->getOperand(OpIdx);
6555- if (auto *CI = dyn_cast<ConstantInt>(Op))
6540+ if (auto *CI = dyn_cast<ConstantInt>(V))
65566541 return CI->getValue().isPowerOf2();
65576542 return false;
65586543 });
6559- const bool IsNegatedPowerOfTwo = all_of(VL, [& ](Value *V) {
6544+ const bool IsNegatedPowerOfTwo = all_of(VL, [](Value *V) {
65606545 // TODO: We should allow undef elements here
6561- const auto *I = dyn_cast<Instruction>(V);
6562- if (!I) {
6563- assert((isa<UndefValue>(V) ||
6564- I0->getOpcode() == Instruction::GetElementPtr) &&
6565- "Expected undef or GEP.");
6566- return true;
6567- }
6568- const auto *Op = I->getOperand(OpIdx);
6569- if (auto *CI = dyn_cast<ConstantInt>(Op))
6546+ if (auto *CI = dyn_cast<ConstantInt>(V))
65706547 return CI->getValue().isNegatedPowerOf2();
65716548 return false;
65726549 });
@@ -7973,8 +7950,8 @@ BoUpSLP::getEntryCost(const TreeEntry *E, ArrayRef<Value *> VectorizedVals,
79737950 };
79747951 auto GetVectorCost = [=](InstructionCost CommonCost) {
79757952 unsigned OpIdx = isa<UnaryOperator>(VL0) ? 0 : 1;
7976- TTI::OperandValueInfo Op1Info = getOperandInfo(VL , 0);
7977- TTI::OperandValueInfo Op2Info = getOperandInfo(VL , OpIdx);
7953+ TTI::OperandValueInfo Op1Info = getOperandInfo(*E , 0);
7954+ TTI::OperandValueInfo Op2Info = getOperandInfo(*E , OpIdx);
79787955 return TTI->getArithmeticInstrCost(ShuffleOrOp, VecTy, CostKind, Op1Info,
79797956 Op2Info) +
79807957 CommonCost;
@@ -8030,7 +8007,7 @@ BoUpSLP::getEntryCost(const TreeEntry *E, ArrayRef<Value *> VectorizedVals,
80308007 bool IsReorder = !E->ReorderIndices.empty();
80318008 auto GetScalarCost = [=](unsigned Idx) {
80328009 auto *VI = cast<StoreInst>(VL[Idx]);
8033- TTI::OperandValueInfo OpInfo = getOperandInfo(VI, 0 );
8010+ TTI::OperandValueInfo OpInfo = TTI:: getOperandInfo(VI->getValueOperand() );
80348011 return TTI->getMemoryOpCost(Instruction::Store, ScalarTy, VI->getAlign(),
80358012 VI->getPointerAddressSpace(), CostKind,
80368013 OpInfo, VI);
@@ -8039,7 +8016,7 @@ BoUpSLP::getEntryCost(const TreeEntry *E, ArrayRef<Value *> VectorizedVals,
80398016 cast<StoreInst>(IsReorder ? VL[E->ReorderIndices.front()] : VL0);
80408017 auto GetVectorCost = [=](InstructionCost CommonCost) {
80418018 // We know that we can merge the stores. Calculate the cost.
8042- TTI::OperandValueInfo OpInfo = getOperandInfo(VL , 0);
8019+ TTI::OperandValueInfo OpInfo = getOperandInfo(*E , 0);
80438020 return TTI->getMemoryOpCost(Instruction::Store, VecTy, BaseSI->getAlign(),
80448021 BaseSI->getPointerAddressSpace(), CostKind,
80458022 OpInfo) +
0 commit comments