Skip to content

Commit

Permalink
Track guard/call pair if constrainIfcmpeqne cannot remove guard
Browse files Browse the repository at this point in the history
If constrainIfcmpeqne cannot call canFoldNonOverriddenGuard because the
target has too many predecessor blocks, the guard/call pair should still
be added to the _callNodeToGuardNodes list.  That allows constrainCall
the opportunity to check whether the guard can be removed after all
the guard blocks have been processed.

Also removed a comment from constrainIfcmpeqne describing an invalid
potential improvement.
  • Loading branch information
hzongaro committed Aug 3, 2022
1 parent 1b6af95 commit 5740eae
Showing 1 changed file with 11 additions and 10 deletions.
21 changes: 11 additions & 10 deletions compiler/optimizer/VPHandlers.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -9457,18 +9457,19 @@ static TR::Node *constrainIfcmpeqne(OMR::ValuePropagation *vp, TR::Node *node, b
{
TR::Node *callNode = node->getVirtualCallNodeForGuard();

// In order to decide correctly whether the guard can be eliminated, we need to ensure
// all predecessor blocks of the call block have been walked, and hence all definitions
// used by the call have been considered. The easiest way to do that is to check
// whether the call has only one predecessor - the current block.
// A potential refinement would be to check whether all of the call block's predecessors
// have been walked, and that this is the last predecessor being visited on this walk.
//
if (callNode &&
callNode->getOpCode().isCall() &&
target->getPredecessors().size() == 1)
callNode->getOpCode().isCall())
{
virtualGuardWillBeEliminated = canFoldNonOverriddenGuard(vp, callNode, node);
// In order to decide correctly whether the guard can be eliminated, we need to ensure
// all predecessor blocks of the call block have been walked, and hence all definitions
// used by the call have been considered. The easiest way to do that is to check
// whether the call has only one predecessor - the current block.
//
if (target->getPredecessors().size() == 1)
{
virtualGuardWillBeEliminated = canFoldNonOverriddenGuard(vp, callNode, node);
}

if (!virtualGuardWillBeEliminated &&
vp->lastTimeThrough() &&
vp->_isGlobalPropagation)
Expand Down

0 comments on commit 5740eae

Please sign in to comment.