[PATCH] D132886: [SLP]Improve operands kind analaysis for constants.
Alexey Bataev via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Tue Aug 30 06:36:45 PDT 2022
This revision was landed with ongoing or failed builds.
This revision was automatically updated to reflect the committed changes.
Closed by commit rGafbf5466ba0e: [SLP]Improve operands kind analaysis for constants. (authored by ABataev).
Repository:
rG LLVM Github Monorepo
CHANGES SINCE LAST ACTION
https://reviews.llvm.org/D132886/new/
https://reviews.llvm.org/D132886
Files:
llvm/lib/Transforms/Vectorize/SLPVectorizer.cpp
Index: llvm/lib/Transforms/Vectorize/SLPVectorizer.cpp
===================================================================
--- llvm/lib/Transforms/Vectorize/SLPVectorizer.cpp
+++ llvm/lib/Transforms/Vectorize/SLPVectorizer.cpp
@@ -2125,9 +2125,8 @@
/// Return information about the vector formed for the specified index
/// of a vector of (the same) instruction.
- /// \param EnableFP - If true, check for float constants.
- TargetTransformInfo::OperandValueInfo
- getOperandInfo(ArrayRef<Value *> VL, unsigned OpIdx, bool EnableFP);
+ TargetTransformInfo::OperandValueInfo getOperandInfo(ArrayRef<Value *> VL,
+ unsigned OpIdx);
/// \returns the cost of the vectorizable entry.
InstructionCost getEntryCost(const TreeEntry *E,
@@ -5816,24 +5815,30 @@
}
TTI::OperandValueInfo BoUpSLP::getOperandInfo(ArrayRef<Value *> VL,
- unsigned OpIdx, bool EnableFP) {
- TTI::OperandValueKind VK = TTI::OK_UniformConstantValue;
- TTI::OperandValueProperties VP = TTI::OP_PowerOf2;
-
- // If all float operands are constants then set the operand kind to
+ unsigned OpIdx) {
+ // If all float point constants are the same, return OK_UniformConstantValue.
+ // If all float operands are different constants then set the operand kind to
// OK_NonUniformConstantValue. Otherwise, return OK_AnyValue.
const auto *I0 = cast<Instruction>(VL.front());
if (I0->getOperand(OpIdx)->getType()->isFloatingPointTy()) {
- if (!EnableFP || any_of(VL, [OpIdx, I0](Value *V) {
+ if (any_of(VL, [OpIdx, I0](Value *V) {
const auto *Inst = cast<Instruction>(V);
assert(Inst->getOpcode() == I0->getOpcode() &&
"Expected same opcode");
return !isConstant(Inst->getOperand(OpIdx));
}))
return {TTI::OK_AnyValue, TTI::OP_None};
- return {TTI::OK_NonUniformConstantValue, TTI::OP_None};
+ const auto *Op0 = I0->getOperand(OpIdx);
+ if (any_of(VL, [OpIdx, Op0](Value *V) {
+ return cast<Instruction>(V)->getOperand(OpIdx) != Op0;
+ }))
+ return {TTI::OK_NonUniformConstantValue, TTI::OP_None};
+ return {TTI::OK_UniformConstantValue, TTI::OP_None};
}
+ TTI::OperandValueKind VK = TTI::OK_UniformConstantValue;
+ TTI::OperandValueProperties VP = TTI::OP_PowerOf2;
+
// If all operands are exactly the same ConstantInt then set the
// operand kind to OK_UniformConstantValue.
// If instead not all operands are constants, then set the operand kind
@@ -6430,8 +6435,7 @@
// Certain instructions can be cheaper to vectorize if they have a
// constant second vector operand.
const unsigned OpIdx = isa<BinaryOperator>(VL0) ? 1 : 0;
- // TODO: impact of enabling the analysis there is yet to be determined
- auto Op2Info = getOperandInfo(VL, OpIdx, /*EnableFP=*/false);
+ auto Op2Info = getOperandInfo(VL, OpIdx);
SmallVector<const Value *, 4> Operands(VL0->operand_values());
InstructionCost ScalarEltCost =
@@ -6516,7 +6520,7 @@
auto *SI =
cast<StoreInst>(IsReorder ? VL[E->ReorderIndices.front()] : VL0);
Align Alignment = SI->getAlign();
- TTI::OperandValueInfo OpInfo = getOperandInfo(VL, 0, /*EnableFP=*/true);
+ TTI::OperandValueInfo OpInfo = getOperandInfo(VL, 0);
InstructionCost ScalarEltCost = TTI->getMemoryOpCost(
Instruction::Store, ScalarTy, Alignment, 0, CostKind, OpInfo, VL0);
InstructionCost ScalarStCost = VecTy->getNumElements() * ScalarEltCost;
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D132886.456648.patch
Type: text/x-patch
Size: 3637 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20220830/5d60a22d/attachment.bin>
More information about the llvm-commits
mailing list