[PATCH] D26877: Minor fixes in Loop Strength Reduction
Evgeny Stupachenko via llvm-commits
llvm-commits at lists.llvm.org
Mon Nov 21 14:18:30 PST 2016
evstupac updated this revision to Diff 78784.
evstupac added a comment.
"2. Debug print: ..." committed separately.
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
@@ -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.78784.patch
Type: text/x-patch
Size: 2102 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20161121/feea8905/attachment.bin>
More information about the llvm-commits
mailing list