[PATCH] D26877: Minor fixes in Loop Strength Reduction
Evgeny Stupachenko via llvm-commits
llvm-commits at lists.llvm.org
Fri Nov 18 17:01:44 PST 2016
evstupac created this revision.
evstupac added reviewers: sanjoy, jonpa.
evstupac added subscribers: llvm-commits, sanjoy, jonpa.
evstupac set the repository for this revision to rL LLVM.
Herald added a subscriber: mzolotukhin.
The patch contains the following minor fixes:
1. Function renaming: from specific "Condition Instruction" to general "Instruction".
2. Debug print: form address print to Instruction dump.
3. Set count of first register in best registers search.
Repository:
rL LLVM
https://reviews.llvm.org/D26877
Files:
lib/Transforms/Scalar/LoopStrengthReduce.cpp
Index: lib/Transforms/Scalar/LoopStrengthReduce.cpp
===================================================================
--- lib/Transforms/Scalar/LoopStrengthReduce.cpp
+++ lib/Transforms/Scalar/LoopStrengthReduce.cpp
@@ -1674,7 +1674,7 @@
SmallPtrSet<Use*, MaxChains> IVIncSet;
void OptimizeShadowIV();
- bool FindIVUserForCond(ICmpInst *Cond, IVStrideUse *&CondUse);
+ bool FindIVUserForInst(Instruction *Inst, IVStrideUse *&InstUse);
ICmpInst *OptimizeMax(ICmpInst *Cond, IVStrideUse* &CondUse);
void OptimizeLoopTermCond();
@@ -1896,15 +1896,15 @@
}
}
-/// If Cond has an operand that is an expression of an IV, set the IV user and
+/// If Inst has an operand that is an expression of an IV, set the IV user and
/// stride information and return true, otherwise return false.
-bool LSRInstance::FindIVUserForCond(ICmpInst *Cond, IVStrideUse *&CondUse) {
+bool LSRInstance::FindIVUserForInst(Instruction *Inst, IVStrideUse *&InstUse) {
for (IVStrideUse &U : IU)
- if (U.getUser() == Cond) {
+ if (U.getUser() == Inst) {
// NOTE: we could handle setcc instructions with multiple uses here, but
// InstCombine does it as well for simple uses, it's not clear that it
// occurs enough in real life to handle.
- CondUse = &U;
+ InstUse = &U;
return true;
}
return false;
@@ -2114,7 +2114,7 @@
// Search IVUsesByStride to find Cond's IVUse if there is one.
IVStrideUse *CondUse = nullptr;
ICmpInst *Cond = cast<ICmpInst>(TermBr->getCondition());
- if (!FindIVUserForCond(Cond, CondUse))
+ if (!FindIVUserForInst(Cond, CondUse))
continue;
// If the trip count is computed in terms of a max (due to ScalarEvolution
@@ -2815,7 +2815,7 @@
DEBUG(dbgs() << "Final Chain: " << *Chain.Incs[0].UserInst << "\n");
for (const IVInc &Inc : Chain) {
- DEBUG(dbgs() << " Inc: " << Inc.UserInst << "\n");
+ DEBUG(dbgs() << " Inc: " << *Inc.UserInst << "\n");
auto UseI = find(Inc.UserInst->operands(), Inc.IVOperand);
assert(UseI != Inc.UserInst->op_end() && "cannot find IV operand");
IVIncSet.insert(UseI);
@@ -4144,9 +4144,10 @@
for (const SCEV *Reg : RegUses) {
if (Taken.count(Reg))
continue;
- if (!Best)
+ if (!Best) {
Best = Reg;
- else {
+ BestNum = RegUses.getUsedByIndices(Reg).count();
+ } else {
unsigned Count = RegUses.getUsedByIndices(Reg).count();
if (Count > BestNum) {
Best = Reg;
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D26877.78605.patch
Type: text/x-patch
Size: 2526 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20161119/983455b9/attachment.bin>
More information about the llvm-commits
mailing list