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

Quan Anh Mai qamai at openjdk.org
Mon Nov 25 13:33:29 UTC 2024


On Mon, 25 Nov 2024 13:18:26 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:
> 
>   Improve tests, remove edge case

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

> 486: 
> 487:   const Type* t = phase->type(div->in(2));
> 488:   if (t == TypeClass::ONE) { // Identity?

You can move this into `l == 0 || l == 1` below.

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

> 1182: 
> 1183:   if (con == 1) {
> 1184:     return ConNode::make(TypeClass::ZERO);

This should be in `Value` instead.

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

> 1211:   }
> 1212:   // X MOD X is 0
> 1213:   if (mod->in(1) == mod->in(2)) {

`mod->in(1)->eqv_uncast(mod->in(2))`

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

PR Review Comment: https://git.openjdk.org/jdk/pull/22061#discussion_r1856618565
PR Review Comment: https://git.openjdk.org/jdk/pull/22061#discussion_r1856619372
PR Review Comment: https://git.openjdk.org/jdk/pull/22061#discussion_r1856621633


More information about the hotspot-compiler-dev mailing list