Skip to content

Commit 9a90457

Browse files
committed
[SLP][NFC]Use ArrayReffor operands directly instead of entry/operand number, NFC.
1 parent 42d5567 commit 9a90457

File tree

1 file changed

+11
-14
lines changed

1 file changed

+11
-14
lines changed

llvm/lib/Transforms/Vectorize/SLPVectorizer.cpp

Lines changed: 11 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -2436,8 +2436,7 @@ class BoUpSLP {
24362436

24372437
/// Return information about the vector formed for the specified index
24382438
/// of a vector of (the same) instruction.
2439-
TargetTransformInfo::OperandValueInfo getOperandInfo(const TreeEntry &E,
2440-
unsigned OpIdx);
2439+
TargetTransformInfo::OperandValueInfo getOperandInfo(ArrayRef<Value *> Ops);
24412440

24422441
/// \returns the cost of the vectorizable entry.
24432442
InstructionCost getEntryCost(const TreeEntry *E,
@@ -6559,27 +6558,25 @@ static bool isAlternateInstruction(const Instruction *I,
65596558
return I->getOpcode() == AltOp->getOpcode();
65606559
}
65616560

6562-
TTI::OperandValueInfo BoUpSLP::getOperandInfo(const TreeEntry &E,
6563-
unsigned OpIdx) {
6564-
ArrayRef<Value*> VL = E.getOperand(OpIdx);
6565-
assert(!VL.empty());
6566-
const auto *Op0 = VL.front();
6561+
TTI::OperandValueInfo BoUpSLP::getOperandInfo(ArrayRef<Value *> Ops) {
6562+
assert(!Ops.empty());
6563+
const auto *Op0 = Ops.front();
65676564

6568-
const bool IsConstant = all_of(VL, [](Value *V) {
6565+
const bool IsConstant = all_of(Ops, [](Value *V) {
65696566
// TODO: We should allow undef elements here
65706567
return isConstant(V) && !isa<UndefValue>(V);
65716568
});
6572-
const bool IsUniform = all_of(VL, [=](Value *V) {
6569+
const bool IsUniform = all_of(Ops, [=](Value *V) {
65736570
// TODO: We should allow undef elements here
65746571
return V == Op0;
65756572
});
6576-
const bool IsPowerOfTwo = all_of(VL, [](Value *V) {
6573+
const bool IsPowerOfTwo = all_of(Ops, [](Value *V) {
65776574
// TODO: We should allow undef elements here
65786575
if (auto *CI = dyn_cast<ConstantInt>(V))
65796576
return CI->getValue().isPowerOf2();
65806577
return false;
65816578
});
6582-
const bool IsNegatedPowerOfTwo = all_of(VL, [](Value *V) {
6579+
const bool IsNegatedPowerOfTwo = all_of(Ops, [](Value *V) {
65836580
// TODO: We should allow undef elements here
65846581
if (auto *CI = dyn_cast<ConstantInt>(V))
65856582
return CI->getValue().isNegatedPowerOf2();
@@ -7999,8 +7996,8 @@ BoUpSLP::getEntryCost(const TreeEntry *E, ArrayRef<Value *> VectorizedVals,
79997996
};
80007997
auto GetVectorCost = [=](InstructionCost CommonCost) {
80017998
unsigned OpIdx = isa<UnaryOperator>(VL0) ? 0 : 1;
8002-
TTI::OperandValueInfo Op1Info = getOperandInfo(*E, 0);
8003-
TTI::OperandValueInfo Op2Info = getOperandInfo(*E, OpIdx);
7999+
TTI::OperandValueInfo Op1Info = getOperandInfo(E->getOperand(0));
8000+
TTI::OperandValueInfo Op2Info = getOperandInfo(E->getOperand(OpIdx));
80048001
return TTI->getArithmeticInstrCost(ShuffleOrOp, VecTy, CostKind, Op1Info,
80058002
Op2Info) +
80068003
CommonCost;
@@ -8065,7 +8062,7 @@ BoUpSLP::getEntryCost(const TreeEntry *E, ArrayRef<Value *> VectorizedVals,
80658062
cast<StoreInst>(IsReorder ? VL[E->ReorderIndices.front()] : VL0);
80668063
auto GetVectorCost = [=](InstructionCost CommonCost) {
80678064
// We know that we can merge the stores. Calculate the cost.
8068-
TTI::OperandValueInfo OpInfo = getOperandInfo(*E, 0);
8065+
TTI::OperandValueInfo OpInfo = getOperandInfo(E->getOperand(0));
80698066
return TTI->getMemoryOpCost(Instruction::Store, VecTy, BaseSI->getAlign(),
80708067
BaseSI->getPointerAddressSpace(), CostKind,
80718068
OpInfo) +

0 commit comments

Comments
 (0)