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

Jie Fu jiefu at openjdk.java.net
Fri Feb 25 15:22:54 UTC 2022


On Fri, 25 Feb 2022 12:11:43 GMT, Quan Anh Mai <duke at openjdk.java.net> wrote:

>> Hi,
>> 
>> This patch adds several matching rules for x86_64 backend to use `lea` instructions for several fused arithmetic operations. Also, `lea`s don't kill flags and allow different `dst` and `src`, so it is preferred over `sll` if possible, too. 
>> 
>> Thank you very much.
>
> Quan Anh Mai has updated the pull request incrementally with one additional commit since the last revision:
> 
>   address reviews

I checked your last version of the patch.
It fails to generate `lea` for `testInt3` but both gcc and llvm would generate `lea` with -O{1,2,3}.

    @Benchmark
    public int testInt1() {
        return x + (y << 2) + 32;
    }

    @Benchmark
    public int testInt2() {
        return x + (y << 2);
    }

    @Benchmark
    public int testInt3() {
        return x + y + 16;
    }


Shall we also generate `lea` for testInt3?

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

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


More information about the hotspot-compiler-dev mailing list