[SLP][NFC]Use TreeEntry::getOprand instead of trying to rebuild it in getOperandInfo(), NFC.
This commit is contained in:
parent
26bb2da28b
commit
66c623bfc6
@ -2424,7 +2424,7 @@ private:
|
||||
|
||||
/// Return information about the vector formed for the specified index
|
||||
/// of a vector of (the same) instruction.
|
||||
TargetTransformInfo::OperandValueInfo getOperandInfo(ArrayRef<Value *> VL,
|
||||
TargetTransformInfo::OperandValueInfo getOperandInfo(const TreeEntry &E,
|
||||
unsigned OpIdx);
|
||||
|
||||
/// \returns the cost of the vectorizable entry.
|
||||
@ -6521,52 +6521,29 @@ static bool isAlternateInstruction(const Instruction *I,
|
||||
return I->getOpcode() == AltOp->getOpcode();
|
||||
}
|
||||
|
||||
TTI::OperandValueInfo BoUpSLP::getOperandInfo(ArrayRef<Value *> VL,
|
||||
TTI::OperandValueInfo BoUpSLP::getOperandInfo(const TreeEntry &E,
|
||||
unsigned OpIdx) {
|
||||
ArrayRef<Value*> VL = E.getOperand(OpIdx);
|
||||
assert(!VL.empty());
|
||||
const auto *I0 = cast<Instruction>(*find_if(VL, Instruction::classof));
|
||||
const auto *Op0 = I0->getOperand(OpIdx);
|
||||
const auto *Op0 = VL.front();
|
||||
|
||||
const bool IsConstant = all_of(VL, [&](Value *V) {
|
||||
const bool IsConstant = all_of(VL, [](Value *V) {
|
||||
// TODO: We should allow undef elements here
|
||||
const auto *I = dyn_cast<Instruction>(V);
|
||||
if (!I)
|
||||
return true;
|
||||
auto *Op = I->getOperand(OpIdx);
|
||||
return isConstant(Op) && !isa<UndefValue>(Op);
|
||||
return isConstant(V) && !isa<UndefValue>(V);
|
||||
});
|
||||
const bool IsUniform = all_of(VL, [&](Value *V) {
|
||||
const bool IsUniform = all_of(VL, [=](Value *V) {
|
||||
// TODO: We should allow undef elements here
|
||||
const auto *I = dyn_cast<Instruction>(V);
|
||||
if (!I)
|
||||
return false;
|
||||
return I->getOperand(OpIdx) == Op0;
|
||||
return V == Op0;
|
||||
});
|
||||
const bool IsPowerOfTwo = all_of(VL, [&](Value *V) {
|
||||
const bool IsPowerOfTwo = all_of(VL, [](Value *V) {
|
||||
// TODO: We should allow undef elements here
|
||||
const auto *I = dyn_cast<Instruction>(V);
|
||||
if (!I) {
|
||||
assert((isa<UndefValue>(V) ||
|
||||
I0->getOpcode() == Instruction::GetElementPtr) &&
|
||||
"Expected undef or GEP.");
|
||||
return true;
|
||||
}
|
||||
auto *Op = I->getOperand(OpIdx);
|
||||
if (auto *CI = dyn_cast<ConstantInt>(Op))
|
||||
if (auto *CI = dyn_cast<ConstantInt>(V))
|
||||
return CI->getValue().isPowerOf2();
|
||||
return false;
|
||||
});
|
||||
const bool IsNegatedPowerOfTwo = all_of(VL, [&](Value *V) {
|
||||
const bool IsNegatedPowerOfTwo = all_of(VL, [](Value *V) {
|
||||
// TODO: We should allow undef elements here
|
||||
const auto *I = dyn_cast<Instruction>(V);
|
||||
if (!I) {
|
||||
assert((isa<UndefValue>(V) ||
|
||||
I0->getOpcode() == Instruction::GetElementPtr) &&
|
||||
"Expected undef or GEP.");
|
||||
return true;
|
||||
}
|
||||
const auto *Op = I->getOperand(OpIdx);
|
||||
if (auto *CI = dyn_cast<ConstantInt>(Op))
|
||||
if (auto *CI = dyn_cast<ConstantInt>(V))
|
||||
return CI->getValue().isNegatedPowerOf2();
|
||||
return false;
|
||||
});
|
||||
@ -7973,8 +7950,8 @@ BoUpSLP::getEntryCost(const TreeEntry *E, ArrayRef<Value *> VectorizedVals,
|
||||
};
|
||||
auto GetVectorCost = [=](InstructionCost CommonCost) {
|
||||
unsigned OpIdx = isa<UnaryOperator>(VL0) ? 0 : 1;
|
||||
TTI::OperandValueInfo Op1Info = getOperandInfo(VL, 0);
|
||||
TTI::OperandValueInfo Op2Info = getOperandInfo(VL, OpIdx);
|
||||
TTI::OperandValueInfo Op1Info = getOperandInfo(*E, 0);
|
||||
TTI::OperandValueInfo Op2Info = getOperandInfo(*E, OpIdx);
|
||||
return TTI->getArithmeticInstrCost(ShuffleOrOp, VecTy, CostKind, Op1Info,
|
||||
Op2Info) +
|
||||
CommonCost;
|
||||
@ -8030,7 +8007,7 @@ BoUpSLP::getEntryCost(const TreeEntry *E, ArrayRef<Value *> VectorizedVals,
|
||||
bool IsReorder = !E->ReorderIndices.empty();
|
||||
auto GetScalarCost = [=](unsigned Idx) {
|
||||
auto *VI = cast<StoreInst>(VL[Idx]);
|
||||
TTI::OperandValueInfo OpInfo = getOperandInfo(VI, 0);
|
||||
TTI::OperandValueInfo OpInfo = TTI::getOperandInfo(VI->getValueOperand());
|
||||
return TTI->getMemoryOpCost(Instruction::Store, ScalarTy, VI->getAlign(),
|
||||
VI->getPointerAddressSpace(), CostKind,
|
||||
OpInfo, VI);
|
||||
@ -8039,7 +8016,7 @@ BoUpSLP::getEntryCost(const TreeEntry *E, ArrayRef<Value *> VectorizedVals,
|
||||
cast<StoreInst>(IsReorder ? VL[E->ReorderIndices.front()] : VL0);
|
||||
auto GetVectorCost = [=](InstructionCost CommonCost) {
|
||||
// We know that we can merge the stores. Calculate the cost.
|
||||
TTI::OperandValueInfo OpInfo = getOperandInfo(VL, 0);
|
||||
TTI::OperandValueInfo OpInfo = getOperandInfo(*E, 0);
|
||||
return TTI->getMemoryOpCost(Instruction::Store, VecTy, BaseSI->getAlign(),
|
||||
BaseSI->getPointerAddressSpace(), CostKind,
|
||||
OpInfo) +
|
||||
|
Loading…
x
Reference in New Issue
Block a user