8181872: C1: possible overflow when strength reducing integer multiply by constant

Reviewed-by: kvn
This commit is contained in:
Vladimir Ivanov 2017-06-20 14:37:25 +03:00
parent bc6e52c2b3
commit 2a0ab692f7
6 changed files with 68 additions and 15 deletions

View file

@ -923,8 +923,8 @@ void LIRGenerator::do_ArithmeticOp_Int(ArithmeticOp* x) {
} else {
left_arg->load_item();
if (x->op() == Bytecodes::_imul && right_arg->is_constant()) {
int c = right_arg->get_jint_constant();
if (c > 0 && (is_power_of_2(c) || is_power_of_2(c - 1) || is_power_of_2(c + 1))) {
jint c = right_arg->get_jint_constant();
if (c > 0 && c < max_jint && (is_power_of_2(c) || is_power_of_2(c - 1) || is_power_of_2(c + 1))) {
right_arg->dont_load_item();
} else {
right_arg->load_item();