Skip to content

Commit

Permalink
Add fix for tryToReplaceShiftLandWithRotateInstruction
Browse files Browse the repository at this point in the history
Optimization will not work if the current node is commoned.

Fixes GH-4298

Signed-off-by: Aidan Ha <[email protected]>
  • Loading branch information
AidanHa committed Oct 9, 2019
1 parent 0cededa commit ea19f4d
Showing 1 changed file with 7 additions and 1 deletion.
8 changes: 7 additions & 1 deletion compiler/z/codegen/BinaryEvaluator.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1816,7 +1816,6 @@ OMR::Z::TreeEvaluator::tryToReplaceShiftLandWithRotateInstruction(TR::Node * nod
// RISBG instructions perform unsigned rotation, so if we are selecting the sign bit via the logical AND we cannot
// perform a signed shift because we must preserve the sign bit. In general we cannot handle this case because we are
// not certain our input will be non-negative, hence we must conservatively disallow the optimization in such a case.

if (longConstValue >= 0x8000000000000000LL && shiftAmount != 0 && isSignedShift)
{
return NULL;
Expand All @@ -1826,6 +1825,13 @@ OMR::Z::TreeEvaluator::tryToReplaceShiftLandWithRotateInstruction(TR::Node * nod
{
return NULL;
}
// If the node entered is a common node, then there is no guarantee that the child of the common node will still be alive.
// And when we try to access the value in that node, we might receive values from a node that might've been killed already.
// Thus, The optimization will not work.
if (node->getRegister() != NULL)
{
return NULL;
}
int32_t tZeros = trailingZeroes(longConstValue);
int32_t lZeros = leadingZeroes(longConstValue);
int32_t tOnes = trailingZeroes(~longConstValue);
Expand Down

0 comments on commit ea19f4d

Please sign in to comment.