RFR: 8344026: [s390x] ubsan failure: signed integer overflow in c1_LIRGenerator_s390.cpp [v2]

Amit Kumar amitkumar at openjdk.org
Tue Nov 19 05:20:45 UTC 2024


On Tue, 19 Nov 2024 04:44:00 GMT, Amit Kumar <amitkumar at openjdk.org> wrote:

>> This PR adds `c > 0 && c < max_jint` check in c1_LIRGenerator_s390.cpp. Please look JBS for more info.
>
> Amit Kumar has updated the pull request incrementally with two additional commits since the last revision:
> 
>  - s390x update
>  - ppc changes

I kept the negative check condition `c > 0 && c < max_jint` for s390x for two key reasons:
1. If c is negative, there is no possibility that is_power_of_2 will allow it to pass through for optimised division, so we return false early.
2. Treating negative numbers as inherently negative feels logically correct in this context.

As a result, if `c == -1`, both implementations (for s390x and PPC) will return `true` by performing the negate operation.

 For cases where `c < -1`, both will return `false`. However, on s390x, the condition will avoid performing two extra checks for determining if the value is a power of 2, because it can't be.

Let me know if you would like to modify the PPC implementation.

-------------

PR Comment: https://git.openjdk.org/jdk/pull/22144#issuecomment-2484729604


More information about the hotspot-compiler-dev mailing list