RFR: 8297264: C2: Cast node is not processed again in CCP and keeps a wrong too narrow type which is later replaced by top [v3]

Roberto Castañeda Lozano rcastanedalo at openjdk.org
Fri Dec 2 08:50:54 UTC 2022


On Thu, 1 Dec 2022 14:44:00 GMT, Christian Hagedorn <chagedorn at openjdk.org> wrote:

>> ![image](https://user-images.githubusercontent.com/17833009/205015579-1b6ac082-e992-4828-80f7-ff991964179b.png)
>> 
>> During CCP, we optimize the type of `348 CastII` in `CastIINode::Value()`: It matches the `CmpI/If` pattern because the current type of `119 Phi` is a constant int:
>> https://github.com/openjdk/jdk/blob/9f24a6f43c6a5e1fa92275e0a87af4f1f0603ba3/src/hotspot/share/opto/castnode.cpp#L213-L215
>> 
>> Later in CCP, the type of `119 Phi` is updated and is no longer a constant but `348 CastII` is not processed anymore during CCP and keeps its wrong too narrow type. We apply more loop opts and at some point, the `CastII` is replaced by top because the input type is outside of the wrong type range of the `CastII`. Some data nodes are folded and the graph is left in a broken state and we assert during GCM.
>> 
>> I propose to add a `CastII` node back to the CCP worklist if we find such a `Cmp/If` pattern to ensure that the `CastII` type is correctly set during CCP.
>> 
>> Thanks,
>> Christian
>
> Christian Hagedorn has updated the pull request incrementally with one additional commit since the last revision:
> 
>   Move test to ccp

Thanks for addressing my feedback, Christian! Just one thing, you probably want to update the test package name for consistency.

test/hotspot/jtreg/compiler/ccp/TestCastIIWrongTypeCCP.java line 29:

> 27:  * @summary Test that CastII nodes are added to the CCP worklist if they could have been
> 28:  *          optimized due to a CmpI/If pattern.
> 29:  * @run main/othervm -Xcomp -XX:CompileCommand=compileonly,compiler.c2.TestCastIIWrongTypeCCP::*

Suggestion:

 * @run main/othervm -Xcomp -XX:CompileCommand=compileonly,compiler.ccp.TestCastIIWrongTypeCCP::*

test/hotspot/jtreg/compiler/ccp/TestCastIIWrongTypeCCP.java line 30:

> 28:  *          optimized due to a CmpI/If pattern.
> 29:  * @run main/othervm -Xcomp -XX:CompileCommand=compileonly,compiler.c2.TestCastIIWrongTypeCCP::*
> 30:  *                   compiler.c2.TestCastIIWrongTypeCCP

Suggestion:

 *                   compiler.ccp.TestCastIIWrongTypeCCP

test/hotspot/jtreg/compiler/ccp/TestCastIIWrongTypeCCP.java line 32:

> 30:  *                   compiler.c2.TestCastIIWrongTypeCCP
> 31:  */
> 32: package compiler.c2;

Suggestion:

package compiler.ccp;

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

Changes requested by rcastanedalo (Reviewer).

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


More information about the hotspot-compiler-dev mailing list