diff --git a/compiler/z/codegen/BinaryEvaluator.cpp b/compiler/z/codegen/BinaryEvaluator.cpp index 5f339286b31..f8a347663cc 100644 --- a/compiler/z/codegen/BinaryEvaluator.cpp +++ b/compiler/z/codegen/BinaryEvaluator.cpp @@ -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; @@ -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);