RFR: 8318049: C2: assert(!failure) failed: Missed optimization opportunity in PhaseIterGVN

Emanuel Peter epeter at openjdk.org
Thu Oct 19 10:48:40 UTC 2023


On Thu, 19 Oct 2023 09:51:09 GMT, Emanuel Peter <epeter at openjdk.org> wrote:

>> This patch fixes [JDK-8318049](https://bugs.openjdk.org/browse/JDK-8318049) by informing XorI and XorL nodes in addition to sub and phi nodes when Cast nodes are updated during IGVN. 
>> 
>> The bug manifests when loop optimizations change the IR:
>> ![image](https://github.com/openjdk/jdk/assets/25208576/5274f2cc-a6fb-4ce6-89f4-4a638577901c)
>> 
>> To the following form:
>> ![image](https://github.com/openjdk/jdk/assets/25208576/07bcbec3-f0bb-4d6a-b312-6a459e6b8c0c)
>> 
>> XorI nodes check for that form in their `Value` call, to do the `x ^ x => 0` transformation, checking through casts. As the cast node didn't inform the Xor when it changes, the transformation doesn't have a chance to run.
>> https://github.com/openjdk/jdk/blob/5bd10521eb5e51e76b20e955addd45f76abba6f7/src/hotspot/share/opto/addnode.cpp#L947-L950
>> 
>> I've attached a reduced version of the test found in the bug. Reviews would be appreciated!
>
> test/hotspot/jtreg/compiler/c2/TestNotifyCastToXor.java line 28:
> 
>> 26:  * @bug 8318049
>> 27:  * @summary Test that xor nodes are properly notified when constraint casts change.
>> 28:  * @run main/othervm -Xbatch -Xcomp -XX:-TieredCompilation -XX:CompileOnly=compiler.c2.TestNotifyCastToXor::test -XX:VerifyIterativeGVN=10 compiler.c2.TestNotifyCastToXor
> 
> The line is a bit long, use multiple lines.
> `-Xbatch` is redundant, `-Xcomp` already makes sure things run in the "blocking" mode.

I'm also getting this when running the testing:

Error: VM option 'VerifyIterativeGVN' is develop and is available only in debug version of VM.
Error: Could not create the Java Virtual Machine.
Error: A fatal exception has occurred. Program will exit.

You need to prepend `-XX:+IgnoreUnrecognizedVMOptions`.

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

PR Review Comment: https://git.openjdk.org/jdk/pull/16214#discussion_r1365294767


More information about the hotspot-compiler-dev mailing list