aboutsummaryrefslogtreecommitdiff
path: root/llvm/lib/Transforms/Utils/ScalarEvolutionExpander.cpp
diff options
context:
space:
mode:
authorSimon Pilgrim <llvm-dev@redking.me.uk>2020-10-30 15:05:23 +0000
committerSimon Pilgrim <llvm-dev@redking.me.uk>2020-10-30 15:20:40 +0000
commited577892cf99cced0430c7ecdc9e16f5e76a460b (patch)
treebda92d5bb095f471807110ec09185e5bbf468876 /llvm/lib/Transforms/Utils/ScalarEvolutionExpander.cpp
parent4474d4d49ce1d13e593136f60fcf888ee6ee2947 (diff)
downloadllvm-ed577892cf99cced0430c7ecdc9e16f5e76a460b.zip
llvm-ed577892cf99cced0430c7ecdc9e16f5e76a460b.tar.gz
llvm-ed577892cf99cced0430c7ecdc9e16f5e76a460b.tar.bz2
Use cast<> instead of dyn_cast<> as we dereference the pointers immediately. NFCI.
Fix clang static analyzer warnings - we're better off relying on cast<> asserting on failure rather than a null dereference crash.
Diffstat (limited to 'llvm/lib/Transforms/Utils/ScalarEvolutionExpander.cpp')
-rw-r--r--llvm/lib/Transforms/Utils/ScalarEvolutionExpander.cpp5
1 files changed, 2 insertions, 3 deletions
diff --git a/llvm/lib/Transforms/Utils/ScalarEvolutionExpander.cpp b/llvm/lib/Transforms/Utils/ScalarEvolutionExpander.cpp
index df100d8..877495b 100644
--- a/llvm/lib/Transforms/Utils/ScalarEvolutionExpander.cpp
+++ b/llvm/lib/Transforms/Utils/ScalarEvolutionExpander.cpp
@@ -2368,11 +2368,10 @@ bool SCEVExpander::isHighCostExpansionHelper(
// Assume to be zero-cost.
return false;
case scConstant: {
- auto *Constant = dyn_cast<SCEVConstant>(S);
// Only evalulate the costs of constants when optimizing for size.
if (CostKind != TargetTransformInfo::TCK_CodeSize)
return 0;
- const APInt &Imm = Constant->getAPInt();
+ const APInt &Imm = cast<SCEVConstant>(S)->getAPInt();
Type *Ty = S->getType();
BudgetRemaining -= TTI.getIntImmCostInst(
WorkItem.ParentOpcode, WorkItem.OperandIdx, Imm, Ty, CostKind);
@@ -2412,7 +2411,7 @@ bool SCEVExpander::isHighCostExpansionHelper(
case scSMaxExpr:
case scUMinExpr:
case scSMinExpr: {
- assert(dyn_cast<SCEVNAryExpr>(S)->getNumOperands() > 1 &&
+ assert(cast<SCEVNAryExpr>(S)->getNumOperands() > 1 &&
"Nary expr should have more than 1 operand.");
// The simple nary expr will require one less op (or pair of ops)
// than the number of it's terms.