Skip to content

Commit

Permalink
Move body of ifacmpneSimplifier to new helper
Browse files Browse the repository at this point in the history
In this commit, the helper is only called from the
ifacmpneSimplifier itself, so that there is no functional change.
  • Loading branch information
kevindean12 committed Nov 3, 2023
1 parent d9b7ee2 commit ec4c976
Showing 1 changed file with 25 additions and 20 deletions.
45 changes: 25 additions & 20 deletions compiler/optimizer/OMRSimplifierHandlers.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -13994,31 +13994,18 @@ TR::Node *normalizeCmpSimplifier(TR::Node * node, TR::Block * block, TR::Simplif
return node;
}

//---------------------------------------------------------------------
// Address if compare equal
//

TR::Node *ifacmpeqSimplifier(TR::Node * node, TR::Block * block, TR::Simplifier * s)
static TR::Node *simplifyIfacmpneHelper(TR::Node * node, TR::Block * block, TR::Simplifier * s)
{
// Perform a simplification for the case where an iselect is compared to a
// constant. This is done before simplifyChildren because it may allow
// further transformations to be done on the children.
simplifyISelectCompare(node, s);

if (removeIfToFollowingBlock(node, block, s) == NULL)
return NULL;
s->simplifyChildren(node, block);

TR::Node * firstChild = node->getFirstChild(), * secondChild = node->getSecondChild();

if (firstChild == secondChild)
{
s->conditionalToUnconditional(node, block, true);
s->conditionalToUnconditional(node, block, false);
return node;
}

makeConstantTheRightChild(node, firstChild, secondChild, s);
if (firstChild->getOpCodeValue() == TR::aconst && conditionalBranchFold((firstChild->getAddress()==secondChild->getAddress()), node, firstChild, secondChild, block, s))
if (firstChild->getOpCodeValue() == TR::aconst && conditionalBranchFold((firstChild->getAddress()!=secondChild->getAddress()), node, firstChild, secondChild, block, s))
return node;

// weak symbols aren't necessarily defined, so we have to do the test
Expand All @@ -14034,9 +14021,10 @@ TR::Node *ifacmpeqSimplifier(TR::Node * node, TR::Block * block, TR::Simplifier
}

//---------------------------------------------------------------------
// Address if compare not equal
// Address if compare equal
//
TR::Node *ifacmpneSimplifier(TR::Node * node, TR::Block * block, TR::Simplifier * s)

TR::Node *ifacmpeqSimplifier(TR::Node * node, TR::Block * block, TR::Simplifier * s)
{
// Perform a simplification for the case where an iselect is compared to a
// constant. This is done before simplifyChildren because it may allow
Expand All @@ -14051,12 +14039,12 @@ TR::Node *ifacmpneSimplifier(TR::Node * node, TR::Block * block, TR::Simplifier

if (firstChild == secondChild)
{
s->conditionalToUnconditional(node, block, false);
s->conditionalToUnconditional(node, block, true);
return node;
}

makeConstantTheRightChild(node, firstChild, secondChild, s);
if (firstChild->getOpCodeValue() == TR::aconst && conditionalBranchFold((firstChild->getAddress()!=secondChild->getAddress()), node, firstChild, secondChild, block, s))
if (firstChild->getOpCodeValue() == TR::aconst && conditionalBranchFold((firstChild->getAddress()==secondChild->getAddress()), node, firstChild, secondChild, block, s))
return node;

// weak symbols aren't necessarily defined, so we have to do the test
Expand All @@ -14071,6 +14059,23 @@ TR::Node *ifacmpneSimplifier(TR::Node * node, TR::Block * block, TR::Simplifier
return node;
}

//---------------------------------------------------------------------
// Address if compare not equal
//
TR::Node *ifacmpneSimplifier(TR::Node * node, TR::Block * block, TR::Simplifier * s)
{
// Perform a simplification for the case where an iselect is compared to a
// constant. This is done before simplifyChildren because it may allow
// further transformations to be done on the children.
simplifyISelectCompare(node, s);

if (removeIfToFollowingBlock(node, block, s) == NULL)
return NULL;
s->simplifyChildren(node, block);

return simplifyIfacmpneHelper(node, block, s);
}

//---------------------------------------------------------------------
// If compares that include equality
//
Expand Down

0 comments on commit ec4c976

Please sign in to comment.