RFR: 8324833: Signed integer overflows in ABS [v5]
Dean Long
dlong at openjdk.org
Fri Feb 23 03:49:58 UTC 2024
On Thu, 22 Feb 2024 08:53:24 GMT, Aleksey Shipilev <shade at openjdk.org> wrote:
>> See the details in the bug. I think current `ABS` implementation is beyond repair, and we should just switch to `uabs`.
>>
>> Additional testing:
>> - [x] Linux x86_64 fastdebug, `all` with `-ftrapv` (now fully passes!)
>> - [x] Linux x86_64 fastdebug, `all`
>
> Aleksey Shipilev has updated the pull request incrementally with one additional commit since the last revision:
>
> Fix a place where we cast to jlong after uabs
src/hotspot/share/opto/loopnode.cpp line 1110:
> 1108: loop->is_invariant(range) && loop->is_invariant(offset) &&
> 1109: original_iters_limit / ABS(scale * stride_con) >= min_iters) {
> 1110: reduced_iters_limit = MIN2(reduced_iters_limit, original_iters_limit/ABS(scale));
Mixing signed and unsigned can cause compiler warnings and a change in semantics. And again, checked_cast is not better than a raw cast here. I think it would be better to make min_iters, reduced_iters_limit, original_iters_limit all unsigned.
-------------
PR Review Comment: https://git.openjdk.org/jdk/pull/17617#discussion_r1500185753
More information about the graal-dev
mailing list