RFR: 8281453: New optimization: convert `~x` into `-1-x` when `~x` is used in an arithmetic expression [v12]
Zhiqiang Zang
duke at openjdk.org
Thu Sep 29 17:42:23 UTC 2022
On Thu, 29 Sep 2022 15:17:12 GMT, Quan Anh Mai <qamai at openjdk.org> wrote:
>> I was thinking of which cases we still want to transform even when the `Xornode` is used in a non-arithmetic expression, and the only case I think safe to transform is that when it is used only once and has some arithmetic inside, for example,
>> `return ~(x+c)`.
>
> In that case, you would need to check the `Opcode` of the use similar to the above line. However, I believe that since you have already deferred the transformation, the bitwise transformations should have been finished by then so you don't need to worry about that. I would suggest adding a comment to remind this. And some tests to confirm, such as `(x + y) & ~(x + y) == 0`. Thanks.
Thanks. I agree transformation like `(x + y) & ~(x + y) => 0` should have been covered by idealization from `AndINode` at this point. However, my intention was to catch the case like `return ~(x-1) => return -x`. If we have only line 889 we would not be able to do this because `~(x - 1)` is not used in arithmetic and will not be transformed.
-------------
PR: https://git.openjdk.org/jdk/pull/7376
More information about the hotspot-compiler-dev
mailing list