RFR: 8303970: C2 can not merge homogeneous adjacent two If

Yi Yang yyang at openjdk.org
Fri Mar 10 14:43:26 UTC 2023


Hi, can I have a review for this patch? It adds new Identity for BoolNode to lookup homogenous back-to-back Ifs, i.e. `Bool (CmpX a b)` is identity to `Bool (CmpX b a)`, in this way, we are able to merge 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;
        }
    }

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

Commit messages:
 - 8303970 C2 can not merge homogeneous adjacent two If

Changes: https://git.openjdk.org/jdk/pull/12978/files
 Webrev: https://webrevs.openjdk.org/?repo=jdk&pr=12978&range=00
  Issue: https://bugs.openjdk.org/browse/JDK-8303970
  Stats: 72 lines in 3 files changed: 65 ins; 0 del; 7 mod
  Patch: https://git.openjdk.org/jdk/pull/12978.diff
  Fetch: git fetch https://git.openjdk.org/jdk pull/12978/head:pull/12978

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


More information about the hotspot-compiler-dev mailing list