Skip to content

Commit

Permalink
Revert PR dotnet#105074
Browse files Browse the repository at this point in the history
  • Loading branch information
jakobbotsch committed Jul 18, 2024
1 parent da67dab commit ad6ef02
Showing 1 changed file with 8 additions and 4 deletions.
12 changes: 8 additions & 4 deletions src/coreclr/jit/inductionvariableopts.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1300,7 +1300,7 @@ class StrengthReductionContext
bool InitializeCursors(GenTreeLclVarCommon* primaryIVLcl, ScevAddRec* primaryIV);
bool IsUseExpectedToBeRemoved(BasicBlock* block, Statement* stmt, GenTreeLclVarCommon* tree);
void AdvanceCursors(ArrayStack<CursorInfo>* cursors, ArrayStack<CursorInfo>* nextCursors);
bool CheckAdvancedCursors(ArrayStack<CursorInfo>* cursors, ScevAddRec** nextIV);
bool CheckAdvancedCursors(ArrayStack<CursorInfo>* cursors, int derivedLevel, ScevAddRec** nextIV);
bool StaysWithinManagedObject(ArrayStack<CursorInfo>* cursors, ScevAddRec* addRec);
bool TryReplaceUsesWithNewPrimaryIV(ArrayStack<CursorInfo>* cursors, ScevAddRec* iv);
BasicBlock* FindUpdateInsertionPoint(ArrayStack<CursorInfo>* cursors);
Expand Down Expand Up @@ -1423,7 +1423,7 @@ bool StrengthReductionContext::TryStrengthReduce()

// Verify that all cursors still represent the same IV
ScevAddRec* nextIV = nullptr;
if (!CheckAdvancedCursors(nextCursors, &nextIV))
if (!CheckAdvancedCursors(nextCursors, derivedLevel + 1, &nextIV))
{
break;
}
Expand Down Expand Up @@ -1749,7 +1749,7 @@ void StrengthReductionContext::AdvanceCursors(ArrayStack<CursorInfo>* cursors, A
for (int i = 0; i < nextCursors->Height(); i++)
{
CursorInfo& nextCursor = nextCursors->BottomRef(i);
printf(" [%d] [%06u]: ", i, nextCursor.Tree == nullptr ? 0 : Compiler::dspTreeID(nextCursor.Tree));
printf(" [%d] [%06u]%s: ", i, nextCursor.Tree == nullptr ? 0 : Compiler::dspTreeID(nextCursor.Tree));
if (nextCursor.IV == nullptr)
{
printf("<null IV>");
Expand All @@ -1770,6 +1770,8 @@ void StrengthReductionContext::AdvanceCursors(ArrayStack<CursorInfo>* cursors, A
//
// Parameters:
// cursors - List of cursors that were advanced.
// derivedLevel - The derived level of the advanced IVs. That is, the number
// of times they are derived from the primary IV.
// nextIV - [out] The next derived IV from the subset of advanced
// cursors to now consider strength reducing.
//
Expand All @@ -1781,7 +1783,9 @@ void StrengthReductionContext::AdvanceCursors(ArrayStack<CursorInfo>* cursors, A
// This function may remove cursors from m_cursors1 and m_cursors2 if it
// decides to no longer consider some cursors for strength reduction.
//
bool StrengthReductionContext::CheckAdvancedCursors(ArrayStack<CursorInfo>* cursors, ScevAddRec** nextIV)
bool StrengthReductionContext::CheckAdvancedCursors(ArrayStack<CursorInfo>* cursors,
int derivedLevel,
ScevAddRec** nextIV)
{
*nextIV = nullptr;

Expand Down

0 comments on commit ad6ef02

Please sign in to comment.