RFR: 8344304: [s390x] ubsan: negation of -2147483648 cannot be represented in type 'int'

Amit Kumar amitkumar at openjdk.org
Fri Nov 29 14:00:42 UTC 2024


On Fri, 29 Nov 2024 13:50:00 GMT, Kim Barrett <kbarrett at openjdk.org> wrote:

>> fixes the issue reported by ubsan.
>
> src/hotspot/cpu/s390/c1_LIRAssembler_s390.cpp line 1542:
> 
>> 1540:                         __ z_slfi(lreg, c);
>> 1541:                       }
>> 1542:                       break;
> 
> Would it be simpler to use `java_negate(c)` (from globalDefinitions.hpp)?

Not sure of that actually. I didn't even know that there exists such helper method. Thanks for making me aware. 

I updated current solution in accordance with GCC compiler. So Z don't have a `shi` instruction which can handle 16-bit numbers, so GCC negates the number and adds it with `ahi` instruction. Then for number upto 32bits, `slfi` instruction is emitted for subtraction. 

@RealLucy do you have other thoughts on this ?

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

PR Review Comment: https://git.openjdk.org/jdk/pull/22456#discussion_r1863564531


More information about the hotspot-compiler-dev mailing list