RFR: 8303970: C2 can not merge homogeneous adjacent two If
Quan Anh Mai
qamai at openjdk.org
Fri Mar 10 16:11:13 UTC 2023
On Fri, 10 Mar 2023 14:37:06 GMT, Yi Yang <yyang at openjdk.org> wrote:
> Hi, can I have a review for this patch? It adds new Identity for BoolNode to lookup homogenous integer comparison, i.e. `Bool (CmpX a b)` is identity to `Bool (CmpX b a)`, in this way, we are able to merge the following two "identical" Ifs, which is not before.
>
>
> public static void test(int a, int b) { // ok, identical ifs, apply split_if
> if (a == b) {
> int_field = 0x42;
> } else {
> int_field = 42;
> }
> if (a == b) {
> int_field = 0x42;
> } else {
> int_field = 42;
> }
> }
>
> public static void test(int a, int b) { // do nothing
> if (a == b) {
> int_field = 0x42;
> } else {
> int_field = 42;
> }
> if (b == a) {
> int_field = 0x42;
> } else {
> int_field = 42;
> }
> }
May I ask why is global value numbering not able to merge these 2? Can we modify `BoolNode::hash` and `BoolNode::cmp` to take these into consideration?
Thanks a lot.
-------------
PR: https://git.openjdk.org/jdk/pull/12978
More information about the hotspot-compiler-dev
mailing list