Skip to content

Commit

Permalink
Update (2025.02.24, 2nd)
Browse files Browse the repository at this point in the history
35673: LA port of 8344026: Ubsan: prevent potential integer overflow in c1_LIRGenerator_.cpp file
  • Loading branch information
loongson-jvm authored Feb 24, 2025
1 parent e858a68 commit 57f20bf
Showing 1 changed file with 10 additions and 7 deletions.
17 changes: 10 additions & 7 deletions src/hotspot/cpu/loongarch/c1_LIRGenerator_loongarch_64.cpp
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
/*
* Copyright (c) 2005, 2021, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2021, 2024, Loongson Technology. All rights reserved.
* Copyright (c) 2021, 2025, Loongson Technology. 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
Expand Down Expand Up @@ -274,17 +274,20 @@ void LIRGenerator::cmp_reg_mem(LIR_Condition condition, LIR_Opr reg, LIR_Opr bas
}

bool LIRGenerator::strength_reduce_multiply(LIR_Opr left, jint c, LIR_Opr result, LIR_Opr tmp) {
if (is_power_of_2(c - 1)) {
__ shift_left(left, exact_log2(c - 1), tmp);
juint u_value = (juint)c;
if (is_power_of_2(u_value - 1)) {
__ shift_left(left, exact_log2(u_value - 1), tmp);
__ add(tmp, left, result);
return true;
} else if (is_power_of_2(c + 1)) {
__ shift_left(left, exact_log2(c + 1), tmp);
} else if (is_power_of_2(u_value + 1)) {
__ shift_left(left, exact_log2(u_value + 1), tmp);
__ sub(tmp, left, result);
return true;
} else {
return false;
} else if (c == -1) {
__ negate(left, result);
return true;
}
return false;
}

void LIRGenerator::store_stack_parameter (LIR_Opr item, ByteSize offset_from_sp) {
Expand Down

0 comments on commit 57f20bf

Please sign in to comment.