RFR: 8303970: C2 can not merge homogeneous adjacent two If
Tobias Hartmann
thartmann at openjdk.org
Fri Mar 10 15:34:10 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;
> }
> }
You probably need something similar to this:
https://github.com/openjdk/jdk/blob/5726d31e56530bbe7dee61ae04b126e20cb3611d/src/hotspot/share/opto/graphKit.cpp#L1323-L1327
-------------
PR: https://git.openjdk.org/jdk/pull/12978
More information about the hotspot-compiler-dev
mailing list