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

Nils Eliasson neliasso at openjdk.java.net
Mon Mar 8 21:17:09 UTC 2021


On Mon, 8 Mar 2021 16:15:27 GMT, Marcus G K Williams <github.com+168222+mgkwill at openjdk.org> wrote:

>> 8261671: X86 I2L conversion can be skipped for certain masked positive values
>> 
>> For the following expression:
>>  (long)(value & mask)
>> Where value is of int type and mask is constant (power of two – 1), we can directly generate bzhi instruction to zero the upper bits instead of doing an andl, followed by movslq
>> 
>> Before:
>> Benchmark Mode Cnt Score Error Units
>> SkipIntToLongCast.skipMaskedSmallPositiveCast avgt 15 10.679 ± 1.496 ns/op
>> 
>> 
>> After:
>> Benchmark Mode Cnt Score Error Units
>> SkipIntToLongCast.skipMaskedSmallPositiveCast avgt 15 7.870 ± 0.067 ns/op
>> 
>> Signed-off-by: Marcus G K Williams <marcus.williams at intel.com>
>
> Marcus G K Williams has updated the pull request incrementally with one additional commit since the last revision:
> 
>   Fix copyright formatting, log description
>   
>   Signed-off-by: Marcus G K Williams <marcus.williams at intel.com>

Changes requested by neliasso (Reviewer).

test/hotspot/jtreg/compiler/codegen/BMI2.java line 29:

> 27:  *
> 28:  * @run main/othervm -Xbatch -XX:-TieredCompilation -XX:+UnlockDiagnosticVMOptions -XX:+AbortVMOnCompilationFailure
> 29:  *      -XX:CompileCommand=compileonly,compiler.codegen.BMI2$BMITests::*

It might be better to use "-XX:CompileCommand=dontinline,compiler.codegen.BMI2$BMITests::*" Then the main methods can still be compiled. As long as BMI2$BMITests method isn't inlining other BMI2$BMITests methods this is will just work just fine.

test/hotspot/jtreg/compiler/codegen/BMI2.java line 56:

> 54:             z = BMITests.bzhiI2L(ix, i);
> 55: 
> 56:             for (int i2 = 0; i2 < ITERATIONS; i2++) {

Why are these manually unrolled? They are the same but with different index?

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

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


More information about the hotspot-compiler-dev mailing list