[PATCH] D73712: [SCEV] SCEVExpander::isHighCostExpansion(): assert if TTI is not provided
Roman Lebedev via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Tue Feb 25 12:11:17 PST 2020
This revision was automatically updated to reflect the committed changes.
Closed by commit rG2d8275d72e16: [SCEV] SCEVExpander::isHighCostExpansion(): assert if TTI is not provided (authored by lebedev.ri).
Repository:
rG LLVM Github Monorepo
CHANGES SINCE LAST ACTION
https://reviews.llvm.org/D73712/new/
https://reviews.llvm.org/D73712
Files:
llvm/include/llvm/Analysis/ScalarEvolutionExpander.h
llvm/lib/Analysis/ScalarEvolutionExpander.cpp
Index: llvm/lib/Analysis/ScalarEvolutionExpander.cpp
===================================================================
--- llvm/lib/Analysis/ScalarEvolutionExpander.cpp
+++ llvm/lib/Analysis/ScalarEvolutionExpander.cpp
@@ -2137,7 +2137,7 @@
bool SCEVExpander::isHighCostExpansionHelper(
const SCEV *S, Loop *L, const Instruction *At, int &BudgetRemaining,
- const TargetTransformInfo *TTI, SmallPtrSetImpl<const SCEV *> &Processed) {
+ const TargetTransformInfo &TTI, SmallPtrSetImpl<const SCEV *> &Processed) {
// Was the cost of expansion of this expression already accounted for?
if (!Processed.insert(S).second)
return false; // We have already accounted for this expression.
@@ -2145,13 +2145,16 @@
// If we can find an existing value for this scev available at the point "At"
// then consider the expression cheap.
if (At && getRelatedExistingExpansion(S, At, L))
- return false;
+ return false; // Consider the expression to be free.
- // Zero/One operand expressions
switch (S->getSCEVType()) {
case scUnknown:
case scConstant:
- return false;
+ return false; // Assume to be zero-cost.
+ }
+
+ // Zero/One operand expressions
+ switch (S->getSCEVType()) {
case scTruncate:
return isHighCostExpansionHelper(cast<SCEVTruncateExpr>(S)->getOperand(), L,
At, BudgetRemaining, TTI, Processed);
Index: llvm/include/llvm/Analysis/ScalarEvolutionExpander.h
===================================================================
--- llvm/include/llvm/Analysis/ScalarEvolutionExpander.h
+++ llvm/include/llvm/Analysis/ScalarEvolutionExpander.h
@@ -182,9 +182,12 @@
bool isHighCostExpansion(const SCEV *Expr, Loop *L, unsigned Budget,
const TargetTransformInfo *TTI,
const Instruction *At = nullptr) {
+ assert(TTI && "This function requires TTI to be provided.");
+ if (!TTI) // In assert-less builds, avoid crashing
+ return true; // by always claiming to be high-cost.
SmallPtrSet<const SCEV *, 8> Processed;
int BudgetRemaining = Budget * TargetTransformInfo::TCC_Basic;
- return isHighCostExpansionHelper(Expr, L, At, BudgetRemaining, TTI,
+ return isHighCostExpansionHelper(Expr, L, At, BudgetRemaining, *TTI,
Processed);
}
@@ -329,7 +332,7 @@
/// Recursive helper function for isHighCostExpansion.
bool isHighCostExpansionHelper(const SCEV *S, Loop *L,
const Instruction *At, int &BudgetRemaining,
- const TargetTransformInfo *TTI,
+ const TargetTransformInfo &TTI,
SmallPtrSetImpl<const SCEV *> &Processed);
/// Insert the specified binary operator, doing a small amount of work to
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D73712.246533.patch
Type: text/x-patch
Size: 2908 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20200225/8986c6ef/attachment.bin>
More information about the llvm-commits
mailing list