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

Tobias Hartmann thartmann at openjdk.org
Wed Nov 20 11:38:22 UTC 2024


On Wed, 13 Nov 2024 09:45:37 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

Looks good to me otherwise. Nice tests!

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

> 1156: 
> 1157: template <typename TypeClass, typename Signed>
> 1158: Node* unsigned_mod_ideal(PhaseGVN* phase, bool can_reshape, Node* mod) {

Should this method be static to limit visibility?

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

> 1200: 
> 1201: template <typename TypeClass, typename Unsigned, typename Signed>
> 1202: const Type* unsigned_mod_value(PhaseGVN* phase, const Node* mod) {

Should this method be static to limit visibility?

test/hotspot/jtreg/compiler/c2/irTests/ModINodeIdealizationTests.java line 62:

> 60:             Asserts.assertFalse(shouldThrow, "Expected an exception to be thrown.");
> 61:         } catch (ArithmeticException e) {
> 62:             Asserts.assertTrue(shouldThrow, "Did not expected an exception to be thrown.");

Suggestion:

            Asserts.assertTrue(shouldThrow, "Did not expect an exception to be thrown.");


Same in other tests.

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

Marked as reviewed by thartmann (Reviewer).

PR Review: https://git.openjdk.org/jdk/pull/22061#pullrequestreview-2448340110
PR Review Comment: https://git.openjdk.org/jdk/pull/22061#discussion_r1850146911
PR Review Comment: https://git.openjdk.org/jdk/pull/22061#discussion_r1850147036
PR Review Comment: https://git.openjdk.org/jdk/pull/22061#discussion_r1850141218


More information about the hotspot-compiler-dev mailing list