aboutsummaryrefslogtreecommitdiff
path: root/llvm/lib/Transforms/Utils/SimplifyIndVar.cpp
diff options
context:
space:
mode:
authorMax Kazantsev <mkazantsev@azul.com>2022-12-06 16:35:45 +0700
committerMax Kazantsev <mkazantsev@azul.com>2022-12-06 17:02:26 +0700
commit6dac170140d09c23b305558939dc45416f0ec865 (patch)
tree19f72673b625822801e713c86ceedcfcc7b5b99e /llvm/lib/Transforms/Utils/SimplifyIndVar.cpp
parent1d9f0145905daf0c2e05b829a7b4842c616d9e3e (diff)
downloadllvm-6dac170140d09c23b305558939dc45416f0ec865.zip
llvm-6dac170140d09c23b305558939dc45416f0ec865.tar.gz
llvm-6dac170140d09c23b305558939dc45416f0ec865.tar.bz2
[SCEVExpander] Support cost evaluation of several SCEVs with same budget
This is a follow-up from discussion in D138412. Sometimes we want to evaluate the cost of expansion of several SCEVs together with same budget. For example, if one of them is a bit above cheap limit, and the second one is free, then we still want to expand. Checking each of them with "cheap" limit is a bit more pessimistic. Differential Revision: https://reviews.llvm.org/D138475 Reviewed By: lebedev.ri
Diffstat (limited to 'llvm/lib/Transforms/Utils/SimplifyIndVar.cpp')
-rw-r--r--llvm/lib/Transforms/Utils/SimplifyIndVar.cpp7
1 files changed, 2 insertions, 5 deletions
diff --git a/llvm/lib/Transforms/Utils/SimplifyIndVar.cpp b/llvm/lib/Transforms/Utils/SimplifyIndVar.cpp
index 84adb6a..9f0ad99 100644
--- a/llvm/lib/Transforms/Utils/SimplifyIndVar.cpp
+++ b/llvm/lib/Transforms/Utils/SimplifyIndVar.cpp
@@ -221,11 +221,8 @@ bool SimplifyIndvar::makeIVComparisonInvariant(ICmpInst *ICmp,
// Do not generate something ridiculous.
auto *PHTerm = Preheader->getTerminator();
- if (Rewriter.isHighCostExpansion(InvariantLHS, L, SCEVCheapExpansionBudget,
- TTI, PHTerm))
- return false;
- if (Rewriter.isHighCostExpansion(InvariantRHS, L, SCEVCheapExpansionBudget,
- TTI, PHTerm))
+ if (Rewriter.isHighCostExpansion({ InvariantLHS, InvariantRHS }, L,
+ 2 * SCEVCheapExpansionBudget, TTI, PHTerm))
return false;
auto *NewLHS =
Rewriter.expandCodeFor(InvariantLHS, IVOperand->getType(), PHTerm);