From 9b64ece514cf941ebc727991d97c43453d8a488d Mon Sep 17 00:00:00 2001 From: Matthias Baesken Date: Wed, 29 May 2024 09:11:04 +0000 Subject: [PATCH] 8332904: ubsan ppc64le: c1_LIRGenerator_ppc.cpp:581:21: runtime error: signed integer overflow: 9223372036854775807 + 1 cannot be represented in type 'long int' Reviewed-by: mdoerr, jkern --- src/hotspot/cpu/ppc/assembler_ppc.cpp | 8 ++++---- src/hotspot/cpu/ppc/c1_LIRGenerator_ppc.cpp | 2 +- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/src/hotspot/cpu/ppc/assembler_ppc.cpp b/src/hotspot/cpu/ppc/assembler_ppc.cpp index 018b66310e2..26fc1aacad3 100644 --- a/src/hotspot/cpu/ppc/assembler_ppc.cpp +++ b/src/hotspot/cpu/ppc/assembler_ppc.cpp @@ -1,6 +1,6 @@ /* - * Copyright (c) 1997, 2023, Oracle and/or its affiliates. All rights reserved. - * Copyright (c) 2012, 2023 SAP SE. All rights reserved. + * Copyright (c) 1997, 2024, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2012, 2024 SAP SE. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -78,9 +78,9 @@ int Assembler::branch_destination(int inst, int pos) { // Low-level andi-one-instruction-macro. void Assembler::andi(Register a, Register s, const long ui16) { - if (is_power_of_2(((jlong) ui16)+1)) { + if (is_power_of_2(((unsigned long) ui16)+1)) { // pow2minus1 - clrldi(a, s, 64 - log2i_exact((((jlong) ui16)+1))); + clrldi(a, s, 64 - log2i_exact((((unsigned long) ui16)+1))); } else if (is_power_of_2((jlong) ui16)) { // pow2 rlwinm(a, s, 0, 31 - log2i_exact((jlong) ui16), 31 - log2i_exact((jlong) ui16)); diff --git a/src/hotspot/cpu/ppc/c1_LIRGenerator_ppc.cpp b/src/hotspot/cpu/ppc/c1_LIRGenerator_ppc.cpp index b58defc1847..2caca1dc556 100644 --- a/src/hotspot/cpu/ppc/c1_LIRGenerator_ppc.cpp +++ b/src/hotspot/cpu/ppc/c1_LIRGenerator_ppc.cpp @@ -578,7 +578,7 @@ inline bool can_handle_logic_op_as_uimm(ValueType *type, Bytecodes::Code bc) { is_power_of_2(int_or_long_const) || is_power_of_2(-int_or_long_const))) return true; if (bc == Bytecodes::_land && - (is_power_of_2(int_or_long_const+1) || + (is_power_of_2((unsigned long)int_or_long_const+1) || (Assembler::is_uimm(int_or_long_const, 32) && is_power_of_2(int_or_long_const)) || (int_or_long_const != min_jlong && is_power_of_2(-int_or_long_const)))) return true;