RFR: 8347645: C2: XOR bounded value handling blocks constant folding [v4]

Quan Anh Mai qamai at openjdk.org
Fri Jan 24 03:47:50 UTC 2025


On Thu, 23 Jan 2025 21:43:44 GMT, Johannes Graham <duke at openjdk.org> wrote:

>> Why? `r0->_hi | r1->_hi == 0` would imply `r0->_hi == 0 && r1->_hi == 0`. This means that both operands are constants and should be filtered out from the previous step already.
>
> The symptom I'm seeing with the alternative version is that the build fails with an exception of 
> 
> Creating jdk.net.jmod
> Error: More than one SourceFile attribute
> java.lang.module.InvalidModuleDescriptorException: More than one SourceFile attribute
> 	at java.base/jdk.internal.module.ModuleInfo.invalidModuleDescriptor(ModuleInfo.java:1228)
> 
> I am thinking that's a result of a bad xor. If I change the ``if ( (r0->_lo >= 0) `` to ``if ( (r0->_lo > 0)`` the build works again, but that might just be luck.
> 
> The case I'm concerned about is if `r0->_hi `and `r1->_hi` are both the same power of 2, say for example 4 and both lo values are 0. Then `round_up_power_of_2(4,4)-1` is 3. However, if the runtime value of one arg is 0 and the other is 4, `0 ^ 4 = 4`, which is larger than 3.

Yes you are right, it should be `round_up_power_of_2(juint(r0->_hi | r1->_hi) + 1) - 1`, note that the cast should happen before the addition to avoid signed integer overflow.

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

PR Review Comment: https://git.openjdk.org/jdk/pull/23089#discussion_r1928048309


More information about the hotspot-compiler-dev mailing list