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

Quan Anh Mai qamai at openjdk.org
Thu Nov 28 14:31:41 UTC 2024


On Thu, 28 Nov 2024 13:36:01 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:
> 
>   abs(MIN_INT) is not positive

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

> 486: 
> 487:   const Type* t = phase->type(div->in(2));
> 488:   const TypeClass* tl = t->cast<TypeClass>();

I believe `is_int()` will assert when `t` is not a `TypeInt`, what you want here is a `try_cast` that calls `isa_int()` instead.

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

PR Review Comment: https://git.openjdk.org/jdk/pull/22061#discussion_r1862295237


More information about the hotspot-compiler-dev mailing list