RFR: 8322589: Add Ideal transformation: (~a) & (~b) => ~(a | b)

Emanuel Peter epeter at openjdk.org
Fri Jan 5 16:03:29 UTC 2024


On Fri, 5 Jan 2024 15:51:14 GMT, Emanuel Peter <epeter at openjdk.org> wrote:

>> Hello,
>> 
>> `(~a) & (~b) => ~(a | b)` is a widely seen pattern, for example it is implemented for LLVM [here](https://github.com/llvm/llvm-project/blob/397f1ce9efb4eea1ee10fe4833f733b8c7abd878/llvm/lib/Transforms/InstCombine/InstCombineAndOrXor.cpp#L1616C28-L1616C28); however it is missing in current implementation of hotspot. This pull request adds this transformation and associated tests.
>> 
>> Thanks.
>
> src/hotspot/share/opto/mulnode.cpp line 617:
> 
>> 615:       && phase->type(in(1)->in(2)) == TypeInt::MINUS_1
>> 616:       && in(2)->Opcode() == Op_XorI
>> 617:       && in(1)->in(2) == in(2)->in(2)) {
> 
> minor code style issue: please take the `&&` to the end of the line. That is what I usually see. It also makes reading the lines easier, as they are aligned with the first line.

Suggestion:

      && phase->type(in(2)->in(2)) == TypeInt::MINUS_1) {

Could be nice for symmetry.

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

PR Review Comment: https://git.openjdk.org/jdk/pull/16333#discussion_r1443037674


More information about the hotspot-compiler-dev mailing list