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

Dean Long dlong at openjdk.org
Tue Dec 3 00:00:41 UTC 2024


On Fri, 29 Nov 2024 13:58:08 GMT, Amit Kumar <amitkumar at openjdk.org> wrote:

>> 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 ?

I agree,
`  __ z_afi(lreg, java_negate(c));`
reads better.

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

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


More information about the hotspot-compiler-dev mailing list