RFR: 8280003: C1: Reconsider uses of logical_and immediates in LIRGenerator::do_getObjectSize [v5]

Dean Long dlong at openjdk.java.net
Thu Feb 10 01:41:05 UTC 2022


On Wed, 9 Feb 2022 23:59:30 GMT, Igor Veresov <iveresov at openjdk.org> wrote:

>> src/hotspot/share/c1/c1_LIRGenerator.cpp line 1418:
>> 
>>> 1416:   __ add(length, header_size_long, length);
>>> 1417:   if (round_mask != 0) {
>>> 1418:     LIR_Opr round_mask_opr = load_immediate(~(jlong)round_mask, T_LONG);
>> 
>> Explicitly casting to jlong here seems unnecessary.  We don't do that at line 1425.
>
> It's going to work for the current value of `round_mask` either way, but I think in general I would cast to an `unsigned long` and then flip the bits. A signed cast will fill the upper bits with ones if the original value was negative. It's usually not what you want with masking.

Yes, there is an ambiguity with the old version.  It passes an `int` to longConst(jlong), so the value is signed extended.  If we wanted to treat it as unsigned, we couldn't.

Since we only need the 64-bit T_LONG immediate for _LP64, and only for this one call, I would also be happy with a new load_immediate_64 or load_immediate_jlong that takes a jlong.  Or this section could be changed to use a 32-bit mask and then do the i2l after, like above.  I'm also willing to accept the current changes as is.  I don't have a strong opinion either way.

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

PR: https://git.openjdk.java.net/jdk/pull/7080


More information about the hotspot-compiler-dev mailing list