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

Marcus G K Williams github.com+168222+mgkwill at openjdk.java.net
Wed Mar 10 18:17:06 UTC 2021


On Wed, 10 Mar 2021 01:23:01 GMT, Vladimir Kozlov <kvn at openjdk.org> wrote:

>> 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));
>                  }
>             }
>       }
> }

Thanks @vnkozlov and @neliasso. I've made the changes you suggest.

I'm still unsure about `-XX:CompileCommand=dontinline,compiler.codegen.BMI2$BMITests::*` over `-XX:CompileCommand=compileonly,compiler.codegen.BMI2$BMITests::*` but I will trust in your knowledge and experience in this area. It doesn't materially change the test just how it's run by default and the test should C2 compile and compare 
`bzhiq`
version to 
andI
movslq 

Even  with -XX:+PrintCompilation I'm not able to see this happening in test .jtr using  `-XX:CompileCommand=dontinline,compiler.codegen.BMI2$BMITests::*` and printing assembly, inlining, compilation but perhaps I am reading the logs incorrectly.

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

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


More information about the hotspot-compiler-dev mailing list