Skip to content

Commit

Permalink
Fix byteswapped store optimization on Power
Browse files Browse the repository at this point in the history
Previously, the Power codegen contained an optimization for performing a
store of a byteswapped value in a single instruction. Unfortunately, the
initial implementation of this optimization did not correctly check that
the byteswap node in question was not commoned, which could result in
erratic behaviour. This has now been corrected.

Issue: #5642
Signed-off-by: Ben Thomas <ben@benthomas.ca>
  • Loading branch information
aviansie-ben committed Nov 2, 2020
1 parent 4ede03c commit e93399a
Showing 1 changed file with 9 additions and 3 deletions.
12 changes: 9 additions & 3 deletions compiler/p/codegen/OMRTreeEvaluator.cpp
Expand Up @@ -966,9 +966,11 @@ TR::Register *OMR::Power::TreeEvaluator::istoreEvaluator(TR::Node *node, TR::Cod
}

bool reverseStore = false;
if (valueChild->getOpCodeValue() == TR::ibyteswap)
if (valueChild->getOpCodeValue() == TR::ibyteswap && valueChild->isSingleRefUnevaluated())
{
reverseStore = true;

cg->decReferenceCount(valueChild);
valueChild = valueChild->getFirstChild();
}

Expand Down Expand Up @@ -1149,9 +1151,11 @@ TR::Register *OMR::Power::TreeEvaluator::lstoreEvaluator(TR::Node *node, TR::Cod
}

bool reverseStore = false;
if (valueChild->getOpCodeValue() == TR::lbyteswap)
if (valueChild->getOpCodeValue() == TR::lbyteswap && valueChild->isSingleRefUnevaluated())
{
reverseStore = true;

cg->decReferenceCount(valueChild);
valueChild = valueChild->getFirstChild();
}

Expand Down Expand Up @@ -1457,9 +1461,11 @@ TR::Register *OMR::Power::TreeEvaluator::sstoreEvaluator(TR::Node *node, TR::Cod
}

bool reverseStore = false;
if (valueChild->getOpCodeValue() == TR::sbyteswap)
if (valueChild->getOpCodeValue() == TR::sbyteswap && valueChild->isSingleRefUnevaluated())
{
reverseStore = true;

cg->decReferenceCount(valueChild);
valueChild = valueChild->getFirstChild();
}

Expand Down

0 comments on commit e93399a

Please sign in to comment.