RFR: 8311932: Suboptimal compiled code of nested loop over memory segment
Roland Westrelin
roland at openjdk.org
Fri Nov 17 07:57:42 UTC 2023
On Tue, 14 Nov 2023 09:58:56 GMT, Tobias Hartmann <thartmann 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.
>
> `TestLongRangeChecks.java` fails with `-ea -esa -XX:CompileThreshold=100 -XX:+UnlockExperimentalVMOptions -server -XX:-TieredCompilation`:
>
>
> 1) Method "public static void compiler.c2.irTests.TestLongRangeChecks.testStridePosScalePosInIntLoopShortLoop1(int,int,long,long)" - [Failed IR rules: 2]:
> * @IR rule 1: "@compiler.lib.ir_framework.IR(phase={DEFAULT}, applyIfPlatformAnd={}, applyIfCPUFeatureOr={}, counts={"_#COUNTED_LOOP#_", "1"}, applyIfPlatform={}, applyIfPlatformOr={}, failOn={}, applyIfOr={}, applyIfCPUFeatureAnd={}, applyIf={}, applyIfCPUFeature={}, applyIfAnd={}, applyIfNot={})"
> > Phase "PrintIdeal":
> - counts: Graph contains wrong number of nodes:
> * Constraint 1: "(\\d+(\\s){2}(CountedLoop\\b.*)+(\\s){2}===.*)"
> - Failed comparison: [found] 0 = 1 [given]
> - No nodes matched!
> * @IR rule 2: "@compiler.lib.ir_framework.IR(phase={DEFAULT}, applyIfPlatformAnd={}, applyIfCPUFeatureOr={}, counts={}, applyIfPlatform={}, applyIfPlatformOr={}, failOn={"_#LOOP#_"}, applyIfOr={}, applyIfCPUFeatureAnd={}, applyIf={}, applyIfCPUFeature={}, applyIfAnd={}, applyIfNot={})"
> > Phase "PrintIdeal":
> - failOn: Graph contains forbidden nodes:
> * Constraint 1: "(\\d+(\\s){2}(Loop.*)+(\\s){2}===.*)"
> - Matched forbidden node:
> * 173 Loop === 173 167 170 [[ 173 420 174 ]] inner
>
> 2) Method "public static void compiler.c2.irTests.TestLongRangeChecks.testStridePosScalePosShortLoop(long,long,long,long)" - [Failed IR rules: 2]:
> * @IR rule 1: "@compiler.lib.ir_framework.IR(phase={DEFAULT}, applyIfPlatformAnd={}, applyIfCPUFeatureOr={}, counts={"_#LONG_COUNTED_LOOP#_", "1"}, applyIfPlatform={}, applyIfPlatformOr={}, failOn={}, applyIfOr={}, applyIfCPUFeatureAnd={}, applyIf={}, applyIfCPUFeature={}, applyIfAnd={}, applyIfNot={})"
> > Phase "PrintIdeal":
> - counts: Graph contains wrong number of nodes:
> * Constraint 1: "(\\d+(\\s){2}(LongCountedLoop\\b.*)+(\\s){2}===.*)"
> - Failed comparison: [found] 0 = 1 [given]
> - No nodes matched!
> * @IR rule 2: "@compiler.lib.ir_framework.IR(phase={DEFAULT}, applyIfPlatformAnd={}, applyIfCPUFeatureOr={}, counts={}, applyIfPlatform={}, applyIfPlatformOr={}, failOn={"_#COUNTED_LOOP#_", "_#LOOP#_"}, applyIfOr={}, applyIfCPUFeatureAnd={}, applyIf={}, applyIfCPUFeature={}, applyIfAnd={}, applyIfNot={})"
> > Phase "PrintIdeal":
> - failOn: Graph contains forbidden nodes:
> * Constraint 2: "(\\d+(\\s){2...
@TobiHartmann @chhagedorn thanks for the reviews
-------------
PR Comment: https://git.openjdk.org/jdk/pull/16650#issuecomment-1815891985
More information about the hotspot-compiler-dev
mailing list