RFR: 8282365: Optimize divideUnsigned and remainderUnsigned for constants [v16]
Quan Anh Mai
qamai at openjdk.org
Wed Jul 12 16:28:29 UTC 2023
On Mon, 3 Jul 2023 12:28:49 GMT, Emanuel Peter <epeter at openjdk.org> wrote:
>> Quan Anh Mai has updated the pull request with a new target base due to a merge or a rebase. The pull request now contains 50 commits:
>>
>> - missing java_negate
>> - Merge branch 'master' into unsignedDiv
>> - whitespace
>> - move asserts to use sites
>> - windows complaints
>> - compiler complaints
>> - undefined internal linkage
>> - add tests, special casing large shift
>> - draft
>> - Merge branch 'master' into unsignedDiv
>> - ... and 40 more: https://git.openjdk.org/jdk/compare/5b147eb5...eb1f5dd9
>
> src/hotspot/share/opto/divnode.cpp line 906:
>
>> 904: }
>> 905:
>> 906: // TODO: Improve Value inference of both signed and unsigned division
>
> Did you miss a `TODO` here?
Currently, we only do `Value` for constant folding, we can restrict the value range of the division in a more rigorous way, e.g `min_jint / 3 < x / y < max_jint / 3` if `y > 3`.
> src/hotspot/share/opto/divnode.cpp line 1419:
>
>> 1417: }
>> 1418: juint con = ti->get_con();
>> 1419: const Type* u = phase->type(in(1));
>
> This is a constant foldable bailout? Why do you do it earlier here?
>
> Generally, I'm starting to wonder if all this code duplication makes sense in all the `Ideal` methods?
Yes we bailout to avoid having to do all the calculations. Let me think how to avoid all these duplications.
> src/hotspot/share/opto/divnode.cpp line 1428:
>
>> 1426: return new AndINode(in(1), phase->intcon(con - 1));
>> 1427: }
>> 1428: // TODO: This can be calculated directly, see https://arxiv.org/abs/1902.01961
>
> Stranded `TODO`?
A modulus can be calculated directly without going through the division transformation. Which reduces the cost a little bit.
-------------
PR Review Comment: https://git.openjdk.org/jdk/pull/9947#discussion_r1261426552
PR Review Comment: https://git.openjdk.org/jdk/pull/9947#discussion_r1261428309
PR Review Comment: https://git.openjdk.org/jdk/pull/9947#discussion_r1261430069
More information about the hotspot-compiler-dev
mailing list