Skip to content

Commit 9b64ece

Browse files
committed
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
1 parent 3d4eb15 commit 9b64ece

File tree

2 files changed

+5
-5
lines changed

2 files changed

+5
-5
lines changed

src/hotspot/cpu/ppc/assembler_ppc.cpp

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
/*
2-
* Copyright (c) 1997, 2023, Oracle and/or its affiliates. All rights reserved.
3-
* Copyright (c) 2012, 2023 SAP SE. All rights reserved.
2+
* Copyright (c) 1997, 2024, Oracle and/or its affiliates. All rights reserved.
3+
* Copyright (c) 2012, 2024 SAP SE. All rights reserved.
44
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
55
*
66
* 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) {
7878

7979
// Low-level andi-one-instruction-macro.
8080
void Assembler::andi(Register a, Register s, const long ui16) {
81-
if (is_power_of_2(((jlong) ui16)+1)) {
81+
if (is_power_of_2(((unsigned long) ui16)+1)) {
8282
// pow2minus1
83-
clrldi(a, s, 64 - log2i_exact((((jlong) ui16)+1)));
83+
clrldi(a, s, 64 - log2i_exact((((unsigned long) ui16)+1)));
8484
} else if (is_power_of_2((jlong) ui16)) {
8585
// pow2
8686
rlwinm(a, s, 0, 31 - log2i_exact((jlong) ui16), 31 - log2i_exact((jlong) ui16));

src/hotspot/cpu/ppc/c1_LIRGenerator_ppc.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -578,7 +578,7 @@ inline bool can_handle_logic_op_as_uimm(ValueType *type, Bytecodes::Code bc) {
578578
is_power_of_2(int_or_long_const) ||
579579
is_power_of_2(-int_or_long_const))) return true;
580580
if (bc == Bytecodes::_land &&
581-
(is_power_of_2(int_or_long_const+1) ||
581+
(is_power_of_2((unsigned long)int_or_long_const+1) ||
582582
(Assembler::is_uimm(int_or_long_const, 32) && is_power_of_2(int_or_long_const)) ||
583583
(int_or_long_const != min_jlong && is_power_of_2(-int_or_long_const)))) return true;
584584

0 commit comments

Comments
 (0)