[PATCH] D76434: [SCEV] Query expanded immediate cost at minsize
Sam Parker via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Thu Sep 10 01:07:32 PDT 2020
samparker updated this revision to Diff 290902.
samparker added a comment.
Addressed comments.
CHANGES SINCE LAST ACTION
https://reviews.llvm.org/D76434/new/
https://reviews.llvm.org/D76434
Files:
llvm/lib/Transforms/Utils/ScalarEvolutionExpander.cpp
Index: llvm/lib/Transforms/Utils/ScalarEvolutionExpander.cpp
===================================================================
--- llvm/lib/Transforms/Utils/ScalarEvolutionExpander.cpp
+++ llvm/lib/Transforms/Utils/ScalarEvolutionExpander.cpp
@@ -2184,13 +2184,18 @@
const T *S = cast<T>(WorkItem.S);
int Cost = 0;
- // Object to help map SCEV operands to expanded IR instructions.
+ // Object to help map SCEV operands to expanded IR instructions. For each
+ // operand of the SCEVExpr, in the given WorkItem, we will expand to one or
+ // more instructions. This struct holds the opcode of that instruction as
+ // well as the minimum and maximum operand indices that we should consider
+ // when expanding SCEVExpr, with an arbitary number of operands, to a chain
+ // of instructions.
struct OperationIndices {
- OperationIndices(unsigned Opc, size_t min, size_t max) :
- Opcode(Opc), MinIdx(min), MaxIdx(max) { }
+ OperationIndices(unsigned Opc, int Min, int Max) :
+ Opcode(Opc), MinIdx(Min), MaxIdx(Max) { }
unsigned Opcode;
- size_t MinIdx;
- size_t MaxIdx;
+ int MinIdx;
+ int MaxIdx;
};
// Collect the operations of all the instructions that will be needed to
@@ -2305,8 +2310,8 @@
for (auto &CostOp : Operations) {
for (auto SCEVOp : enumerate(S->operands())) {
// Clamp the index to account for multiple IR operations being chained.
- size_t MinIdx = std::max(SCEVOp.index(), CostOp.MinIdx);
- size_t OpIdx = std::min(MinIdx, CostOp.MaxIdx);
+ int MinIdx = std::max((int)SCEVOp.index(), CostOp.MinIdx);
+ int OpIdx = std::min(MinIdx, CostOp.MaxIdx);
Worklist.emplace_back(CostOp.Opcode, OpIdx, SCEVOp.value());
}
}
@@ -2341,15 +2346,13 @@
: TargetTransformInfo::TCK_RecipThroughput;
if (auto *Constant = dyn_cast<SCEVConstant>(S)) {
- // Only evalulate the costs of constants when optimizing for size.
+ // Consider constants to be free unless we are optimizing for size.
if (CostKind != TargetTransformInfo::TCK_CodeSize)
return 0;
- const APInt &Imm = Constant->getAPInt();
- Type *Ty = S->getType();
BudgetRemaining -=
TTI.getIntImmCostInst(WorkItem.ParentOpcode, WorkItem.OperandIdx,
- Imm, Ty, CostKind);
- return BudgetRemaining < 0;
+ Constant->getAPInt(), S->getType(), CostKind);
+ return false;
} else if (isa<SCEVCastExpr>(S)) {
int Cost =
costAndCollectOperands<SCEVCastExpr>(WorkItem, TTI, CostKind, Worklist);
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D76434.290902.patch
Type: text/x-patch
Size: 2568 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20200910/f309684f/attachment.bin>
More information about the llvm-commits
mailing list