RFR: 8278296: Generalize long range check transformation [v5]

Tobias Hartmann thartmann at openjdk.java.net
Wed Feb 9 07:44:08 UTC 2022


On Wed, 26 Jan 2022 16:04:06 GMT, Roland Westrelin <roland at openjdk.org> wrote:

>> 8259609 (C2: optimize long range checks in long counted loops) only
>> covered the case of a counted loop with a positive stride and a range
>> check with a positive scale. This change generalizes the long range
>> check transformation to all 4 combinations of stride and scale signs.
>> 
>> The stride > 0, scale > 0 case (covered 8259609) was tweaked so it now
>> uses Qmax computed as the inclusive limit of j*K+Q. That helps in
>> generalizing the formulas to other cases.
>> 
>> The addition of PhaseIdealLoop::is_scaled_iv_plus_extra_offset() was
>> required for the case of negative scale in an int loop. The range
>> check then has the shape:
>> 
>> (CmpUL (AddL (ConvI2L (SubI ConI (LshiftI (Phi
>> 
>> with ConI, the zero constant.
>> 
>> This change also addresses this comment from John:
>> 
>> https://github.com/openjdk/jdk/pull/6576#discussion_r765343664
>> 
>> as part of 8276116 (C2: optimize long range checks in int counted loops)
>
> Roland Westrelin has updated the pull request incrementally with one additional commit since the last revision:
> 
>   review

Executed some quick testing and the build failed:

[2022-02-09T07:35:21,066Z] /System/Volumes/Data/mesos/work_dir/slaves/c82600aa-2448-475c-8c08-6f02a5b3f3af-S24361/frameworks/1735e8a2-a1db-478c-8104-60c8b0af87dd-0196/executors/a8285c9b-cd39-45ef-ab77-b0841e9ffa80/runs/2f83fde2-cc8b-421e-90d1-b402cd6b2d90/workspace/open/src/hotspot/share/opto/loopTransform.cpp:2574:47: error: '&&' within '||' [-Werror,-Wlogical-op-parentheses]
[2022-02-09T07:35:21,066Z]     if (is_iv(exp->in(which = 1), iv, exp_bt) && exp->in(2)->is_Con() ||
[2022-02-09T07:35:21,066Z]         ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~ ~~
[2022-02-09T07:35:21,066Z] /System/Volumes/Data/mesos/work_dir/slaves/c82600aa-2448-475c-8c08-6f02a5b3f3af-S24361/frameworks/1735e8a2-a1db-478c-8104-60c8b0af87dd-0196/executors/a8285c9b-cd39-45ef-ab77-b0841e9ffa80/runs/2f83fde2-cc8b-421e-90d1-b402cd6b2d90/workspace/open/src/hotspot/share/opto/loopTransform.cpp:2574:47: note: place parentheses around the '&&' expression to silence this warning
[2022-02-09T07:35:21,066Z]     if (is_iv(exp->in(which = 1), iv, exp_bt) && exp->in(2)->is_Con() ||
[2022-02-09T07:35:21,067Z]                                               ^
[2022-02-09T07:35:21,067Z]         (                                                            )
[2022-02-09T07:35:21,067Z] /System/Volumes/Data/mesos/work_dir/slaves/c82600aa-2448-475c-8c08-6f02a5b3f3af-S24361/frameworks/1735e8a2-a1db-478c-8104-60c8b0af87dd-0196/executors/a8285c9b-cd39-45ef-ab77-b0841e9ffa80/runs/2f83fde2-cc8b-421e-90d1-b402cd6b2d90/workspace/open/src/hotspot/share/opto/loopTransform.cpp:2575:47: error: '&&' within '||' [-Werror,-Wlogical-op-parentheses]
[2022-02-09T07:35:21,067Z]         is_iv(exp->in(which = 2), iv, exp_bt) && exp->in(1)->is_Con()) {
[2022-02-09T07:35:21,067Z]         ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~
[2022-02-09T07:35:21,067Z] /System/Volumes/Data/mesos/work_dir/slaves/c82600aa-2448-475c-8c08-6f02a5b3f3af-S24361/frameworks/1735e8a2-a1db-478c-8104-60c8b0af87dd-0196/executors/a8285c9b-cd39-45ef-ab77-b0841e9ffa80/runs/2f83fde2-cc8b-421e-90d1-b402cd6b2d90/workspace/open/src/hotspot/share/opto/loopTransform.cpp:2575:47: note: place parentheses around the '&&' expression to silence this warning
[2022-02-09T07:35:21,067Z]         is_iv(exp->in(which = 2), iv, exp_bt) && exp->in(1)->is_Con()) {
[2022-02-09T07:35:21,067Z]                                               ^

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

PR: https://git.openjdk.java.net/jdk/pull/6989


More information about the hotspot-compiler-dev mailing list