RFR: 8332268: C2: Add missing optimizations for UDivI/L and UModI/L and unify the shared logic with the signed nodes [v2]

Quan Anh Mai qamai at openjdk.org
Mon Nov 25 13:18:27 UTC 2024


On Mon, 25 Nov 2024 11:56:18 GMT, theoweidmannoracle <duke at openjdk.org> wrote:

>> This PR introduces
>> - several new optimizations to unsigned division and modulo
>>    - x % 1, x % x, x % 2^k
>>    - x / 1, x / x, x / 2^k 
>>    - does not implement the Granlund and Montgomery algorithm, which has been implemented for signed modulo division in the past. It is unclear if a lot is to be gained by implementing this.
>> - tests to test existing optimizations for signed division and modulo 
>>    - does not test the Granlund and Montgomery algorithm directly
>
> theoweidmannoracle has updated the pull request incrementally with one additional commit since the last revision:
> 
>   Resolve review comments

src/hotspot/share/opto/divnode.cpp line 507:

> 505:     return nullptr;
> 506:   }
> 507:   Signed l = tl->get_con(); // Get divisor

You should get the unsigned type instead.

src/hotspot/share/opto/divnode.cpp line 513:

> 511:   }
> 512: 
> 513:   if (l == min_jint) {

Why excluding this case? You can move the check of division by 1 down here I think.

src/hotspot/share/opto/type.hpp line 2173:

> 2171: 
> 2172: template <>
> 2173: inline const TypeInt* Type::is<TypeInt>() const {

I think `cast` would be a better name

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

PR Review Comment: https://git.openjdk.org/jdk/pull/22061#discussion_r1856592007
PR Review Comment: https://git.openjdk.org/jdk/pull/22061#discussion_r1856591175
PR Review Comment: https://git.openjdk.org/jdk/pull/22061#discussion_r1856588364


More information about the hotspot-compiler-dev mailing list