RFR: 8375653: C2: CmpUNode::sub is not monotonic [v2]

Quan Anh Mai qamai at openjdk.org
Thu Jan 22 05:21:12 UTC 2026


On Thu, 22 Jan 2026 04:33:45 GMT, Dean Long <dlong at openjdk.org> wrote:

>> Quan Anh Mai has updated the pull request incrementally with one additional commit since the last revision:
>> 
>>   A little more detailed explanation
>
> src/hotspot/share/opto/subnode.cpp line 758:
> 
>> 756:   // (This is a gross hack, since the sub method never
>> 757:   // looks at the structure of the node in any other case.)
>> 758:   if (r0->_lo >= 0 && r1->_lo >= 0 && is_index_range_check()) {
> 
> Do we still need this after improvements like JDK-8356813?

Yes, that only solves the issue when the divisor is constant, this helps when the divisor is not a constant as well.

> src/hotspot/share/opto/subnode.cpp line 767:
> 
>> 765:     return TypeInt::CC_GT;
>> 766:   } else if (r0->is_con() && r1->is_con()) {
>> 767:     assert(r0->get_con() == r1->get_con(), "must be equal");
> 
> Please explain why this assert must be true.  Does it need a comment?

Done! The reason is that here we have `r0->_ulo == r0->_uhi` and `r1->_ulo == r1->_uhi`. So if `r0->_ulo != r1->_ulo`, we must reach a previous branch instead.

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

PR Review Comment: https://git.openjdk.org/jdk/pull/29308#discussion_r2715335794
PR Review Comment: https://git.openjdk.org/jdk/pull/29308#discussion_r2715334761


More information about the hotspot-compiler-dev mailing list