RFR: 8261008: Optimize Xor
Vladimir Kozlov
kvn at openjdk.java.net
Mon Mar 1 20:45:44 UTC 2021
On Mon, 1 Mar 2021 14:24:14 GMT, Eric Liu <github.com+10482586+theRealELiu at openjdk.org> wrote:
>> If we agree that this optimization is desired, then it makes sense to also write optimizations for `x - x` and `x | x`.
>>
>> However, how often do these patterns occur in real code? Can you provide some examples (of source code from OSS projects) where `x ^ x`, `x - x`, or `x | x` occur?
>
>> If we agree that this optimization is desired, then it makes sense to also write optimizations for `x - x` and `x | x`.
>>
>> However, how often do these patterns occur in real code? Can you provide some examples (of source code from OSS projects) where `x ^ x`, `x - x`, or `x | x` occur?
>
> Thanks for your feedback. I didn't find them in real cases. This case was discussed in https://mail.openjdk.java.net/pipermail/hotspot-compiler-dev/2020-November/041798.html.
>
> To persue the optimal code, it could be done without too much effort.
`x - x` is already optimized: https://github.com/openjdk/jdk/blob/master/src/hotspot/share/opto/subnode.cpp#L96
`x | x` - here: https://github.com/openjdk/jdk/blob/master/src/hotspot/share/opto/addnode.cpp#L781
For `x ^ x` Value() method should be used as for SubNode.
-------------
PR: https://git.openjdk.java.net/jdk/pull/2776
More information about the hotspot-compiler-dev
mailing list