RFR: 8281453: New optimization: convert "c-(~x)" into "x+(c+1)" and "~(c-x)" into "x+(-c-1)" [v7]

Zhiqiang Zang duke at openjdk.java.net
Wed Apr 13 18:40:22 UTC 2022


On Wed, 13 Apr 2022 17:56:56 GMT, Vladimir Kozlov <kvn at openjdk.org> wrote:

>> Zhiqiang Zang has updated the pull request with a new target base due to a merge or a rebase. The pull request now contains ten commits:
>> 
>>  - merge master.
>>  - clean.
>>  - merge tests into XXXINodeIdealizationTests
>>  - clean.
>>  - Merge branch 'master'.
>>  - convert ~x into -1-x when ~x is part of Add and Sub.
>>  - include bug id.
>>  - include a microbenmark.
>>  - Convert c-(~x) into x+(c+1) in SubNode and convert ~(c-x) into x+(-c-1) in XorNode.
>
> Optimization you proposed does not match RFE description and title.
> 
> You do only:  `~x` or (x ^ (-1))` -> `(-1 - x)`
> 
> As result this should be Xor nodes ideal transformation. I don't even think you need such transformation if `rhs` and `lhs` are not constants because I assume `XOR` and `SUB` hw instructions have the same latency.
> 
> I suggest you to redo performance testing after you merged #7795 changes.

Thanks for reviewing. @vnkozlov 
> Optimization you proposed does not match RFE description and title.

The initial description is somewhat out of date because I adopted @merykitty 's suggestion to include all the cases enabled from `~x => -1-x` instead of adding them one by one, such as `(~x)+c -> (c-1)-x`, which exist in current code base, and many new idealisation enabled from `~x => -1-x` such as `c-(~x) => x + (c+1)`, `~x - ~y => y - x`, `(x+1) + ~y => x - y` I did not update description and title because I'd like to keep history somehow. Please let me know if I should.

> I suggest you to redo performance testing after you merged #7795 changes.

Will redo and post results.

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

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


More information about the hotspot-compiler-dev mailing list