RFR: 8282204: Use lea instructions for arithmetic operations on x86_64 [v4]

Quan Anh Mai duke at openjdk.java.net
Fri Feb 25 12:30:00 UTC 2022


On Fri, 25 Feb 2022 07:22:19 GMT, Jie Fu <jiefu at openjdk.org> wrote:

>> Quan Anh Mai has updated the pull request incrementally with one additional commit since the last revision:
>> 
>>   add benchmark
>
> test/micro/org/openjdk/bench/vm/compiler/LeaInstruction.java line 32:
> 
>> 30: @BenchmarkMode(Mode.AverageTime)
>> 31: @OutputTimeUnit(TimeUnit.NANOSECONDS)
>> 32: @Fork(value = 2, jvmArgsAppend = {"-XX:LoopUnrollLimit=1"})
> 
> Why we need `-XX:LoopUnrollLimit=1`?

Because our benchmark computation involves constants, loop unrolling leads to the constants being hoisted outside, leading to us not actually measuring the desired.

> test/micro/org/openjdk/bench/vm/compiler/LeaInstruction.java line 43:
> 
>> 41:         int x = this.x;
>> 42:         for (int i = 0; i < ITERATION; i++) {
>> 43:             x = x * 4 + 10;
> 
> Do we need `bh.consume(x)` here?

Yes, it's my bad copying things.
Thank you very much.

> test/micro/org/openjdk/bench/vm/compiler/LeaInstruction.java line 53:
> 
>> 51:             x = x + y + 10;
>> 52:             y = x + y + 20;
>> 53:             bh.consume(x);
> 
> I would suggest `bh.consume` to be out of the for loop.

Done

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

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


More information about the hotspot-compiler-dev mailing list