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