Skip to content

Commit 2fd85d7

Browse files
author
Dan Gohman
committed
Filter out illegal formulae after updating offsets, not before, so that
formulae which become illegal as a result of the offset updating don't escape. This is for rdar://8529692. No testcase yet, because the given cases hit use-list ordering differences. llvm-svn: 116093
1 parent a5af410 commit 2fd85d7

File tree

1 file changed

+18
-18
lines changed

1 file changed

+18
-18
lines changed

llvm/lib/Transforms/Scalar/LoopStrengthReduce.cpp

Lines changed: 18 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -2992,24 +2992,6 @@ void LSRInstance::NarrowSearchSpaceByCollapsingUnrolledCode() {
29922992

29932993
LUThatHas->AllFixupsOutsideLoop &= LU.AllFixupsOutsideLoop;
29942994

2995-
// Delete formulae from the new use which are no longer legal.
2996-
bool Any = false;
2997-
for (size_t i = 0, e = LUThatHas->Formulae.size(); i != e; ++i) {
2998-
Formula &F = LUThatHas->Formulae[i];
2999-
if (!isLegalUse(F.AM,
3000-
LUThatHas->MinOffset, LUThatHas->MaxOffset,
3001-
LUThatHas->Kind, LUThatHas->AccessTy, TLI)) {
3002-
DEBUG(dbgs() << " Deleting "; F.print(dbgs());
3003-
dbgs() << '\n');
3004-
LUThatHas->DeleteFormula(F);
3005-
--i;
3006-
--e;
3007-
Any = true;
3008-
}
3009-
}
3010-
if (Any)
3011-
LUThatHas->RecomputeRegs(LUThatHas - &Uses.front(), RegUses);
3012-
30132995
// Update the relocs to reference the new use.
30142996
for (SmallVectorImpl<LSRFixup>::iterator I = Fixups.begin(),
30152997
E = Fixups.end(); I != E; ++I) {
@@ -3032,6 +3014,24 @@ void LSRInstance::NarrowSearchSpaceByCollapsingUnrolledCode() {
30323014
Fixup.LUIdx = LUIdx;
30333015
}
30343016

3017+
// Delete formulae from the new use which are no longer legal.
3018+
bool Any = false;
3019+
for (size_t i = 0, e = LUThatHas->Formulae.size(); i != e; ++i) {
3020+
Formula &F = LUThatHas->Formulae[i];
3021+
if (!isLegalUse(F.AM,
3022+
LUThatHas->MinOffset, LUThatHas->MaxOffset,
3023+
LUThatHas->Kind, LUThatHas->AccessTy, TLI)) {
3024+
DEBUG(dbgs() << " Deleting "; F.print(dbgs());
3025+
dbgs() << '\n');
3026+
LUThatHas->DeleteFormula(F);
3027+
--i;
3028+
--e;
3029+
Any = true;
3030+
}
3031+
}
3032+
if (Any)
3033+
LUThatHas->RecomputeRegs(LUThatHas - &Uses.front(), RegUses);
3034+
30353035
// Delete the old use.
30363036
DeleteUse(LU, LUIdx);
30373037
--LUIdx;

0 commit comments

Comments
 (0)