RFR: 8311932: Suboptimal compiled code of nested loop over memory segment [v2]

Christian Hagedorn chagedorn at openjdk.org
Wed Nov 15 12:27:38 UTC 2023


On Tue, 14 Nov 2023 12:38:41 GMT, Roland Westrelin <roland at openjdk.org> wrote:

>> To enable the elimination of long range checks, the loop that contains
>> the range checks is transformed into a loop nest and the range checks
>> are changed to operate on int values computed before the loop is
>> entered. This causes extra overhead out of loop and once, the range
>> checks are eliminated, can only pay off if the loop is executed for
>> long enough. This change disable the transformation if the trip count
>> computed from profile data is too low. This came up with a
>> MemorySegment API micro benchmarks and improves performance
>> significantly.
>
> Roland Westrelin has updated the pull request incrementally with one additional commit since the last revision:
> 
>   -XX:+TieredCompilation

Looks good!

src/hotspot/share/opto/loopnode.cpp line 861:

> 859:   if (range_checks.size() > 0) {
> 860:     // This transformation requires peeling one iteration. Also, if it has range checks and they are eliminated by
> 861:     // predication, then 2 predicates are added for one range check. Finally, transforming a long range check requires

Nit: I suggest to use the precise names:
Suggestion:

    // Loop Predication, then 2 Hoisted Check Predicates are added for one range check. Finally, transforming a long range check requires

test/hotspot/jtreg/compiler/c2/irTests/TestLongRangeChecks.java line 41:

> 39: public class TestLongRangeChecks {
> 40:     public static void main(String[] args) {
> 41:         TestFramework.runWithFlags("-XX:+TieredCompilation", "-XX:-UseCountedLoopSafepoints", "-XX:LoopUnrollLimit=0");

You could add `8311932` to the `@bug` numbers above.

test/hotspot/jtreg/compiler/c2/irTests/TestLongRangeChecks.java line 270:

> 268:     @Test
> 269:     @IR(counts = { IRNode.COUNTED_LOOP, "1" })
> 270:     @IR(failOn = { IRNode.LOOP})

Suggestion:

    @IR(failOn = { IRNode.LOOP })

test/hotspot/jtreg/compiler/c2/irTests/TestLongRangeChecks.java line 288:

> 286:     @Test
> 287:     @IR(counts = { IRNode.COUNTED_LOOP, "1" })
> 288:     @IR(failOn = { IRNode.LOOP})

Suggestion:

    @IR(failOn = { IRNode.LOOP })

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

Marked as reviewed by chagedorn (Reviewer).

PR Review: https://git.openjdk.org/jdk/pull/16650#pullrequestreview-1731907786
PR Review Comment: https://git.openjdk.org/jdk/pull/16650#discussion_r1394120877
PR Review Comment: https://git.openjdk.org/jdk/pull/16650#discussion_r1394129779
PR Review Comment: https://git.openjdk.org/jdk/pull/16650#discussion_r1394130057
PR Review Comment: https://git.openjdk.org/jdk/pull/16650#discussion_r1394130269


More information about the hotspot-compiler-dev mailing list