[llvm] 9a90457 - [SLP][NFC]Use ArrayReffor operands directly instead of entry/operand number, NFC.
Alexey Bataev via llvm-commits
llvm-commits at lists.llvm.org
Mon Sep 11 11:16:23 PDT 2023
Author: Alexey Bataev
Date: 2023-09-11T11:16:13-07:00
New Revision: 9a90457a7647822b39983858d8da7ef1841ce89a
URL: https://github.com/llvm/llvm-project/commit/9a90457a7647822b39983858d8da7ef1841ce89a
DIFF: https://github.com/llvm/llvm-project/commit/9a90457a7647822b39983858d8da7ef1841ce89a.diff
LOG: [SLP][NFC]Use ArrayReffor operands directly instead of entry/operand number, NFC.
Added:
Modified:
llvm/lib/Transforms/Vectorize/SLPVectorizer.cpp
Removed:
################################################################################
diff --git a/llvm/lib/Transforms/Vectorize/SLPVectorizer.cpp b/llvm/lib/Transforms/Vectorize/SLPVectorizer.cpp
index dc22b3b4f80a24d..7f2d54cf146553e 100644
--- a/llvm/lib/Transforms/Vectorize/SLPVectorizer.cpp
+++ b/llvm/lib/Transforms/Vectorize/SLPVectorizer.cpp
@@ -2436,8 +2436,7 @@ class BoUpSLP {
/// Return information about the vector formed for the specified index
/// of a vector of (the same) instruction.
- TargetTransformInfo::OperandValueInfo getOperandInfo(const TreeEntry &E,
- unsigned OpIdx);
+ TargetTransformInfo::OperandValueInfo getOperandInfo(ArrayRef<Value *> Ops);
/// \returns the cost of the vectorizable entry.
InstructionCost getEntryCost(const TreeEntry *E,
@@ -6559,27 +6558,25 @@ static bool isAlternateInstruction(const Instruction *I,
return I->getOpcode() == AltOp->getOpcode();
}
-TTI::OperandValueInfo BoUpSLP::getOperandInfo(const TreeEntry &E,
- unsigned OpIdx) {
- ArrayRef<Value*> VL = E.getOperand(OpIdx);
- assert(!VL.empty());
- const auto *Op0 = VL.front();
+TTI::OperandValueInfo BoUpSLP::getOperandInfo(ArrayRef<Value *> Ops) {
+ assert(!Ops.empty());
+ const auto *Op0 = Ops.front();
- const bool IsConstant = all_of(VL, [](Value *V) {
+ const bool IsConstant = all_of(Ops, [](Value *V) {
// TODO: We should allow undef elements here
return isConstant(V) && !isa<UndefValue>(V);
});
- const bool IsUniform = all_of(VL, [=](Value *V) {
+ const bool IsUniform = all_of(Ops, [=](Value *V) {
// TODO: We should allow undef elements here
return V == Op0;
});
- const bool IsPowerOfTwo = all_of(VL, [](Value *V) {
+ const bool IsPowerOfTwo = all_of(Ops, [](Value *V) {
// TODO: We should allow undef elements here
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(Ops, [](Value *V) {
// TODO: We should allow undef elements here
if (auto *CI = dyn_cast<ConstantInt>(V))
return CI->getValue().isNegatedPowerOf2();
@@ -7999,8 +7996,8 @@ BoUpSLP::getEntryCost(const TreeEntry *E, ArrayRef<Value *> VectorizedVals,
};
auto GetVectorCost = [=](InstructionCost CommonCost) {
unsigned OpIdx = isa<UnaryOperator>(VL0) ? 0 : 1;
- TTI::OperandValueInfo Op1Info = getOperandInfo(*E, 0);
- TTI::OperandValueInfo Op2Info = getOperandInfo(*E, OpIdx);
+ TTI::OperandValueInfo Op1Info = getOperandInfo(E->getOperand(0));
+ TTI::OperandValueInfo Op2Info = getOperandInfo(E->getOperand(OpIdx));
return TTI->getArithmeticInstrCost(ShuffleOrOp, VecTy, CostKind, Op1Info,
Op2Info) +
CommonCost;
@@ -8065,7 +8062,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(*E, 0);
+ TTI::OperandValueInfo OpInfo = getOperandInfo(E->getOperand(0));
return TTI->getMemoryOpCost(Instruction::Store, VecTy, BaseSI->getAlign(),
BaseSI->getPointerAddressSpace(), CostKind,
OpInfo) +
More information about the llvm-commits
mailing list