RFR: 8261671: X86 I2L conversion can be skipped for certain masked positive values [v7]

Vladimir Kozlov kvn at openjdk.java.net
Wed Mar 10 01:26:07 UTC 2021


On Wed, 10 Mar 2021 00:18:31 GMT, Marcus G K Williams <github.com+168222+mgkwill at openjdk.org> wrote:

>> Sounds reasonable.
>
> I tried to use "-XX:CompileCommand=dontinline,compiler.codegen.BMI2$BMITests::*" however I'm unable to directly verify the C2 compilation of bzhiI2L() method and therefor bzhiq instructions that should be generated. I see the testZeroBzhiI2L() testOneBzhiI2L() methods get compiled and they both make a static call to  bzhiI2L() but it doesn't appear to be C2 compiled.
> 
> I'm using the following command: 'make test TEST="jtreg:test/hotspot/jtreg/compiler/codegen/BMI2.java" JTREG="VM_OPTIONS=-XX:+UnlockDiagnosticVMOptions -XX:-TieredCompilation -XX:+PrintAssembly -Xbatch -XX:CompileCommand=print,compiler.codegen.BMI2$BMITests::* -XX:CompileCommand=dontinline,compiler.codegen.BMI2$BMITests::*" CONF=linux-x86_64-server-slowdebug'
> 
> But I've tried many variations. If I use "-XX:CompileCommand=compileonly,compiler.codegen.BMI2$BMITests::*" I can manually verify that bzhiq is generated by C2 compiler.
> 
> I'd prefer to leave this as is unless I'm missing something.

Nils's suggestion is reasonable. With "compileonly,compiler.codegen.BMI2$BMITests::*" the test will be slow because BMI2::test*BzhiI2L() methods are not compiled.
 Use -XX:+PrintCompilation to see what is going on with compilations. I think you will see several recompilations until all switch cases are executed. That is why I want loops in test*BzhiI2L() be inverted (ITERATIONS as external loop) - you will get final code version much sooner. You can preserve golden values (first run) in array to compare later.
BTW, you don't need 2 methods - pass `ix` as parameter.

public static void testBzhiI2L(int ix) {
       long[] goldv = new long[16];
       for (int i = 0; i <= 15; i++) {
             goldv[i] = BMITests.bzhiI2L(ix, i);
       }
       for (int i2 = 0; i2 < ITERATIONS; i2++) {
            for (int i = 0; i <= 15; i++) {
                 long v = BMITests.bzhiI2L(ix, i);
                 if (v != goldv[i]) {
                         throw new Error(returnBzhiI2LErrMessage (gold[i], v));
                 }
            }
      }
}

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

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


More information about the hotspot-compiler-dev mailing list