RFR: 8278114: New addnode ideal optimization: converting "x + x" into "x << 1" [v3]

Mai Đặng Quân Anh duke at openjdk.java.net
Thu Dec 16 18:40:04 UTC 2021


On Wed, 8 Dec 2021 19:31:35 GMT, Zhiqiang Zang <duke at openjdk.java.net> wrote:

>> A new ideal optimization can be introduced for addnode: converting "x + x" into "x << 1".
>> 
>> 
>> // Convert "x + x" into "x << 1"
>> if (in1 == in2) {
>>   return new LShiftINode(in1, phase->intcon(1));
>> }
>
> Zhiqiang Zang has updated the pull request with a new target base due to a merge or a rebase. The pull request now contains three commits:
> 
>  - Merge master.
>  - enrich tests and do the same transformation for "long".
>  - include a new optimization for ideal in addnode: Convert "x + x" into "x << 1", and associated tests.

Tbh I don't find this transformation necessary, `x + x` is a very cheap operation and is generally easier for the optimiser to work with than `x << 1`.
Cheers.

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

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


More information about the hotspot-compiler-dev mailing list