RFR: 8304049: C2 can not merge trivial Ifs due to CastII
Tobias Hartmann
thartmann at openjdk.org
Mon Mar 20 07:28:19 UTC 2023
On Wed, 15 Mar 2023 10:37:03 GMT, Yi Yang <yyang at openjdk.org> wrote:
> Hi can I have a review for this patch? C2 can not apply Split If for the attached trivial case. PhiNode::Ideal removes itself by unique_input but introduces a new CastII
>
> https://github.com/openjdk/jdk/blob/e3777b0c49abb9cc1925f4044392afadf3adef61/src/hotspot/share/opto/cfgnode.cpp#L1470-L1474
>
> https://github.com/openjdk/jdk/blob/e3777b0c49abb9cc1925f4044392afadf3adef61/src/hotspot/share/opto/cfgnode.cpp#L2078-L2079
>
> Therefore we have two Cmp, which is not identical for split_if.
>
> 
> (Fig1. Phi#41 is removed during ideal, create CastII#58 then)
>
> 
> (Fig2. CmpI#42 and CmpI#23 are different comparisons, they are not identical_backtoback_ifs )
>
> This patch adds Cmp identity to find existing Cmp node, i.e. Cmp#42 is identity to Cmp#23
>
>
> public static void test5(int a, int b){
>
> if( b!=0) {
> int_field = 35;
> } else {
> int_field =222;
> }
>
> if( b!=0) {
> int_field = 35;
> } else {
> int_field =222;
> }
> }
>
>
>
> Test: tier1, application/ctw/modules
I agree with Roland and would also like this to be merged into `PhaseIdealLoop::identical_backtoback_ifs`.
-------------
PR: https://git.openjdk.org/jdk/pull/13039
More information about the hotspot-compiler-dev
mailing list