RFR: 8303970: C2 can not merge homogeneous adjacent two If [v2]

Yi Yang yyang at openjdk.org
Mon Mar 13 06:34:03 UTC 2023


> 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;
>         }
>     }

Yi Yang has updated the pull request incrementally with one additional commit since the last revision:

  dont apply Identity for dead bool

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

Changes:
  - all: https://git.openjdk.org/jdk/pull/12978/files
  - new: https://git.openjdk.org/jdk/pull/12978/files/8d54fb4c..f85fac8f

Webrevs:
 - full: https://webrevs.openjdk.org/?repo=jdk&pr=12978&range=01
 - incr: https://webrevs.openjdk.org/?repo=jdk&pr=12978&range=00-01

  Stats: 22 lines in 2 files changed: 12 ins; 5 del; 5 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