Skip to content

Commit

Permalink
Minor cleanup of PRE code
Browse files Browse the repository at this point in the history
1)This commit deletes some inactive code in the PRE optimization.
2)There were some old mentions that were renamed to exception check removal.
3)Finally tracing was improved in the cost benefit part of PRE.

Signed-off-by: Vijay Sundaresan vijaysun@ca.ibm.com
  • Loading branch information
vijaysun-omr committed Dec 20, 2021
1 parent 7589ce4 commit f6ffd12
Showing 1 changed file with 11 additions and 41 deletions.
52 changes: 11 additions & 41 deletions compiler/optimizer/PartialRedundancy.cpp
Expand Up @@ -436,7 +436,7 @@ int32_t TR_PartialRedundancy::perform()
}
}

// Perform expression dominance and redundant expression adjustment
// Perform exception check motion and redundant expression adjustment
// to obtain 'real' solution for checks. Solution till this point is
// optimistic in that it ignores exception-ordering constraints in Java.
// This step figures out if code motion for checks can in fact be done.
Expand Down Expand Up @@ -612,7 +612,7 @@ int32_t TR_PartialRedundancy::perform()
weight = weight * nextNode->getFrequency();

if (trace())
traceMsg(comp(), "Benefit block_%d benefit %d\n", nextNode->getNumber(), weight);
traceMsg(comp(), "Benefit block_%d benefit %d expr %d\n", nextNode->getNumber(), weight, nextOptimalComputation);
benefit = benefit + weight;
}

Expand All @@ -625,18 +625,10 @@ int32_t TR_PartialRedundancy::perform()
weight = weight * nextNode->getFrequency();

if (trace())
traceMsg(comp(), "Cost block_%d cost %d\n", nextNode->getNumber(), weight);
traceMsg(comp(), "Cost block_%d cost %d expr %d\n", nextNode->getNumber(), weight, nextOptimalComputation);
cost = cost + weight;
}
}

if (((_rednSetInfo[nextNode->getNumber()]->get(nextOptimalComputation)) ||
(_optSetInfo[nextNode->getNumber()]->get(nextOptimalComputation))) &&
(
false ))
{
invalidateOptimalComputation(nextOptimalComputation);
}
}

if (cost > benefit)
Expand Down Expand Up @@ -1846,28 +1838,6 @@ void TR_PartialRedundancy::eliminateRedundantComputations(TR::Block *block, TR::
if (_exceptionCheckMotion)
_profilingWalk = false;
}

#if 0
// No need to walk trees again since we already walked through all of them
if (!walkedTreesAtLeastOnce)
{
TR::TreeTop *currentTree = startTree;
TR::TreeTop *exitTree = block->getExit();
vcount_t visitCount = comp()->incOrResetVisitCount();
while (currentTree != exitTree)
{
TR::ILOpCode &firstOpCodeInTree = currentTree->getNode()->getOpCode();

// Try to profile some exprs
//
if (!block->isCold())
eliminateRedundantSupportedNodes(NULL, currentTree->getNode(), false, currentTree, block->getNumber(), visitCount, NULL, anticipatabilityInfo, supportedNodesAsArray);

currentTree = currentTree->getNextTreeTop();
}
}
#endif

}


Expand Down Expand Up @@ -2292,7 +2262,7 @@ TR_ExceptionCheckMotion::TR_ExceptionCheckMotion(TR::Compilation *comp, TR::Opti
//
// Conservatively this is the maximum number of elements
// that could possibly be in the actual optimal set for this
// block after expression dominance. All elements in optimistic opt
// block after exception check motion. All elements in optimistic opt
// list info can obviously be there and elements in redundant list
// may also be there eventually if they could NOT be moved to the
// program point that is optimal (according to PRE) because of expression
Expand Down Expand Up @@ -2432,7 +2402,7 @@ int32_t TR_ExceptionCheckMotion::perform()
_tryAnotherIteration = true;
_trySecondBestSolution = false;
//
// Try at most NUM_ITERATIONS iterations of expression dominance and redundant expression
// Try at most NUM_ITERATIONS iterations of exception check motion and redundant expression
// adjustment; basically keep iterating till some list changes
// If there is no change in less than NUM_ITERATIONS iterations we will
// detect that we have a converged solution and return
Expand Down Expand Up @@ -2503,7 +2473,7 @@ int32_t TR_ExceptionCheckMotion::perform()
exprsNotRedundant->empty();
}

// Actually do the expression dominance analysis
// Actually do the exception check motion
//
bool redundantSetAdjustmentRequired = false;
initializeGenAndKillSetInfo();
Expand Down Expand Up @@ -2551,7 +2521,7 @@ int32_t TR_ExceptionCheckMotion::perform()

// Now add the other optimal expressions for this block
// (dependent on ordering) as computed by this iteration of
// expression dominance
// exception check motion
//
if (_orderedOptList[i] != NULL)
{
Expand All @@ -2575,7 +2545,7 @@ int32_t TR_ExceptionCheckMotion::perform()

// If there is a difference between the optimistic optimal info
// computed by PRE and the actual optimal info computed as a result of applying
// expression ordering constraints in expression dominance, then
// expression ordering constraints in exception check motion, then
// we need to adjust the optimistic redundant set info for some blocks
// as some expression(s) that were assumed to be optimal in this block
// are no longer optimal
Expand All @@ -2592,7 +2562,7 @@ int32_t TR_ExceptionCheckMotion::perform()
// that dominate other blocks where it is redundant
//
// We also compute global register assignment info in this final pass
// before leaving expression dominance; this uses the
// before leaving exception check motion; this uses the
// availability information computed by redundant expression
// adjustment
//
Expand Down Expand Up @@ -4925,7 +4895,7 @@ bool TR_ExceptionCheckMotion::analyzeBlockStructure(TR_BlockStructure *blockStru
// We are now ready to add whichever expressions are optimal in this block
// into the ordered opt list for this block. Note that there may be some
// elements in the ordered opt list for this block already (from prev
// iterations of expression dominance) in which case we would like to append the
// iterations of exception check motion) in which case we would like to append the
// current solution to the already existing opt list. Also we would like
// to prune the ordered list going out of this block (OUT in dataflow terms)
// based on the check expressions already in the ordered opt list for this block; this
Expand Down Expand Up @@ -6043,7 +6013,7 @@ void TR_RedundantExpressionAdjustment::analyzeNode(TR::Node *, vcount_t, TR_Bloc

// Analysis for adjusting the redundant info sets corresponding to the dynamic
// changes being made to the optimal info sets (because of expression ordering
// constraints). Done after each iteration of expression dominance to keep the
// constraints). Done after each iteration of exception check motion to keep the
// optimal/redundant sets correct at each stage of the iterative process
//
TR_RedundantExpressionAdjustment::TR_RedundantExpressionAdjustment(TR::Compilation *comp, TR::Optimizer *optimizer, TR_Structure *rootStructure, TR_ExceptionCheckMotion *exceptionCheckMotion)
Expand Down

0 comments on commit f6ffd12

Please sign in to comment.