RFR: 8281453: New optimization: convert `~x` into `-1-x` when `~x` is used in an arithmetic expression [v9]

Zhiqiang Zang duke at openjdk.org
Mon Sep 19 16:14:45 UTC 2022


On Mon, 19 Sep 2022 03:23:32 GMT, Quan Anh Mai <duke at openjdk.org> wrote:

>> Zhiqiang Zang has updated the pull request incrementally with one additional commit since the last revision:
>> 
>>   include microbenchmark.
>
> Consider there are 2 statements:
> 
>     int x = ~a + b;
>     int y = ~a | c;
> 
> Your transformation would duplicate the `~a` as it is transformed into `(-a - 1)` in the calculation of `x` but not in the calculation of `y`.
> 
> Thanks.

Thanks @merykitty  So do you mean we want to do the transformation only when ~a has one use, i.e., `outcnt() == 1`? This makes sense to me.

However I still don't get why it should be done in `XOrNode`. Could you shed light on this?

> Consider there are 2 statements:
> 
> ```
> int x = ~a + b;
> int y = ~a | c;
> ```
> 
> Your transformation would duplicate the `~a` as it is transformed into `(-a - 1)` in the calculation of `x` but not in the calculation of `y`.
> 
> Thanks.

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

PR: https://git.openjdk.org/jdk/pull/7376


More information about the hotspot-compiler-dev mailing list