Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add fix for tryToReplaceShiftLandWithRotateInstruction #4427

Merged
merged 1 commit into from
Oct 10, 2019
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Formatting fix

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