@@ -2424,7 +2424,7 @@ class BoUpSLP {
2424
2424
2425
2425
/// Return information about the vector formed for the specified index
2426
2426
/// of a vector of (the same) instruction.
2427
- TargetTransformInfo::OperandValueInfo getOperandInfo(ArrayRef<Value *> VL ,
2427
+ TargetTransformInfo::OperandValueInfo getOperandInfo(const TreeEntry &E ,
2428
2428
unsigned OpIdx);
2429
2429
2430
2430
/// \returns the cost of the vectorizable entry.
@@ -6521,52 +6521,29 @@ static bool isAlternateInstruction(const Instruction *I,
6521
6521
return I->getOpcode() == AltOp->getOpcode();
6522
6522
}
6523
6523
6524
- TTI::OperandValueInfo BoUpSLP::getOperandInfo(ArrayRef<Value *> VL ,
6524
+ TTI::OperandValueInfo BoUpSLP::getOperandInfo(const TreeEntry &E ,
6525
6525
unsigned OpIdx) {
6526
+ ArrayRef<Value*> VL = E.getOperand(OpIdx);
6526
6527
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();
6529
6529
6530
- const bool IsConstant = all_of(VL, [& ](Value *V) {
6530
+ const bool IsConstant = all_of(VL, [](Value *V) {
6531
6531
// 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);
6537
6533
});
6538
- const bool IsUniform = all_of(VL, [& ](Value *V) {
6534
+ const bool IsUniform = all_of(VL, [= ](Value *V) {
6539
6535
// 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;
6544
6537
});
6545
- const bool IsPowerOfTwo = all_of(VL, [& ](Value *V) {
6538
+ const bool IsPowerOfTwo = all_of(VL, [](Value *V) {
6546
6539
// 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))
6556
6541
return CI->getValue().isPowerOf2();
6557
6542
return false;
6558
6543
});
6559
- const bool IsNegatedPowerOfTwo = all_of(VL, [& ](Value *V) {
6544
+ const bool IsNegatedPowerOfTwo = all_of(VL, [](Value *V) {
6560
6545
// 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))
6570
6547
return CI->getValue().isNegatedPowerOf2();
6571
6548
return false;
6572
6549
});
@@ -7973,8 +7950,8 @@ BoUpSLP::getEntryCost(const TreeEntry *E, ArrayRef<Value *> VectorizedVals,
7973
7950
};
7974
7951
auto GetVectorCost = [=](InstructionCost CommonCost) {
7975
7952
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);
7978
7955
return TTI->getArithmeticInstrCost(ShuffleOrOp, VecTy, CostKind, Op1Info,
7979
7956
Op2Info) +
7980
7957
CommonCost;
@@ -8030,7 +8007,7 @@ BoUpSLP::getEntryCost(const TreeEntry *E, ArrayRef<Value *> VectorizedVals,
8030
8007
bool IsReorder = !E->ReorderIndices.empty();
8031
8008
auto GetScalarCost = [=](unsigned Idx) {
8032
8009
auto *VI = cast<StoreInst>(VL[Idx]);
8033
- TTI::OperandValueInfo OpInfo = getOperandInfo(VI, 0 );
8010
+ TTI::OperandValueInfo OpInfo = TTI:: getOperandInfo(VI->getValueOperand() );
8034
8011
return TTI->getMemoryOpCost(Instruction::Store, ScalarTy, VI->getAlign(),
8035
8012
VI->getPointerAddressSpace(), CostKind,
8036
8013
OpInfo, VI);
@@ -8039,7 +8016,7 @@ BoUpSLP::getEntryCost(const TreeEntry *E, ArrayRef<Value *> VectorizedVals,
8039
8016
cast<StoreInst>(IsReorder ? VL[E->ReorderIndices.front()] : VL0);
8040
8017
auto GetVectorCost = [=](InstructionCost CommonCost) {
8041
8018
// 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);
8043
8020
return TTI->getMemoryOpCost(Instruction::Store, VecTy, BaseSI->getAlign(),
8044
8021
BaseSI->getPointerAddressSpace(), CostKind,
8045
8022
OpInfo) +
0 commit comments