JDK-8329531 : compiler/c2/irTests/TestIfMinMax.java fails with IRViolationException: There were one or multiple IR rule failures.
  • Type: Bug
  • Component: hotspot
  • Sub-Component: compiler
  • Affected Version: 23
  • Priority: P4
  • Status: Resolved
  • Resolution: Fixed
  • OS: generic
  • CPU: generic
  • Submitted: 2024-04-02
  • Updated: 2024-04-29
  • Resolved: 2024-04-24
The Version table provides details related to the release that this issue/RFE will be addressed.

Unresolved : Release in which this issue/RFE will be addressed.
Resolved: Release in which this issue/RFE has been resolved.
Fixed : Release in which this issue/RFE has been fixed. The release containing this fix may be available for download as an Early Access Release or a General Availability Release.

To download the current JDK release, click here.
JDK 23
23 b20Fixed
Related Reports
Relates :  
Relates :  
Description
The following test failed in the JDK23 CI:

compiler/c2/irTests/TestIfMinMax.java

Here's a snippet from a linux-aarch64 failure log:

----------System.err:(45/5404)*----------

Command Line:
/opt/mach5/mesos/work_dir/jib-master/install/jdk-23+17-1336/linux-aarch64-debug.jdk/jdk-23/fastdebug/bin/java -DReproduce=true -cp /opt/mach5/mesos/work_dir/slaves/0db9c48f-6638-40d0-9a4b-bd9cc7533eb8-S16544/frameworks/1735e8a2-a1db-478c-8104-60c8b0af87dd-0196/executors/9f9dd7a9-0410-4271-aa1d-68779c1236d8/runs/6354bd54-7450-461c-bd4f-08b0dc43537b/testoutput/test-support/jtreg_open_test_hotspot_jtreg_tier1_compiler_1/classes/3/compiler/c2/irTests/TestIfMinMax.d:/opt/mach5/mesos/work_dir/jib-master/install/jdk-23+17-1336/src.full/open/test/hotspot/jtreg/compiler/c2/irTests:/opt/mach5/mesos/work_dir/slaves/0db9c48f-6638-40d0-9a4b-bd9cc7533eb8-S16544/frameworks/1735e8a2-a1db-478c-8104-60c8b0af87dd-0196/executors/9f9dd7a9-0410-4271-aa1d-68779c1236d8/runs/6354bd54-7450-461c-bd4f-08b0dc43537b/testoutput/test-support/jtreg_open_test_hotspot_jtreg_tier1_compiler_1/classes/3/test/lib:/opt/mach5/mesos/work_dir/slaves/0db9c48f-6638-40d0-9a4b-bd9cc7533eb8-S16544/frameworks/1735e8a2-a1db-478c-8104-60c8b0af87dd-0196/executors/9f9dd7a9-0410-4271-aa1d-68779c1236d8/runs/6354bd54-7450-461c-bd4f-08b0dc43537b/testoutput/test-support/jtreg_open_test_hotspot_jtreg_tier1_compiler_1/classes/3:/opt/mach5/mesos/work_dir/jib-master/install/jtreg/7.3.1/1/bundles/jtreg-7.3.1+1.zip/jtreg/lib/jtreg.jar:/opt/mach5/mesos/work_dir/jib-master/install/jtreg/7.3.1/1/bundles/jtreg-7.3.1+1.zip/jtreg/lib/junit-platform-console-standalone-1.9.2.jar:/opt/mach5/mesos/work_dir/jib-master/install/jtreg/7.3.1/1/bundles/jtreg-7.3.1+1.zip/jtreg/lib/testng-7.3.0.jar:/opt/mach5/mesos/work_dir/jib-master/install/jtreg/7.3.1/1/bundles/jtreg-7.3.1+1.zip/jtreg/lib/jcommander-1.82.jar:/opt/mach5/mesos/work_dir/jib-master/install/jtreg/7.3.1/1/bundles/jtreg-7.3.1+1.zip/jtreg/lib/guice-5.1.0.jar -Djava.library.path=/opt/mach5/mesos/work_dir/jib-master/install/jdk-23+17-1336/linux-aarch64-debug.test/hotspot/jtreg/native -Xbootclasspath/a:. -XX:+UnlockDiagnosticVMOptions -XX:+WhiteBoxAPI -XX:MaxRAMPercentage=6.25 -Dtest.boot.jdk=/opt/mach5/mesos/work_dir/jib-master/install/jdk/21/35/bundles/linux-aarch64/jdk-21_linux-aarch64_bin.tar.gz/jdk-21 -Djava.io.tmpdir=/opt/mach5/mesos/work_dir/slaves/0db9c48f-6638-40d0-9a4b-bd9cc7533eb8-S16544/frameworks/1735e8a2-a1db-478c-8104-60c8b0af87dd-0196/executors/9f9dd7a9-0410-4271-aa1d-68779c1236d8/runs/6354bd54-7450-461c-bd4f-08b0dc43537b/testoutput/test-support/jtreg_open_test_hotspot_jtreg_tier1_compiler_1/tmp -ea -esa -XX:+UnlockExperimentalVMOptions -server -XX:-TieredCompilation -Dir.framework.server.port=36277 -XX:+PrintCompilation -XX:+UnlockDiagnosticVMOptions -XX:+LogCompilation -XX:CompilerDirectivesFile=test-vm-compile-commands-pid-1915292.log -XX:CompilerDirectivesLimit=241 -XX:-OmitStackTraceInFastThrow -DShouldDoIRVerification=true -XX:-BackgroundCompilation -XX:CompileCommand=quiet compiler.lib.ir_framework.test.TestVM compiler.c2.irTests.TestIfMinMax

One or more @IR rules failed:

Failed IR Rules (1) of Methods (1)
----------------------------------
1) Method "public java.lang.Object[] compiler.c2.irTests.TestIfMinMax.testMinIntReduction(int[],int[])" - [Failed IR rules: 1]:
   * @IR rule 1: "@compiler.lib.ir_framework.IR(phase={DEFAULT}, applyIfPlatformAnd={}, applyIfCPUFeatureOr={"sse4.1", "true", "asimd", "true"}, counts={"_#MIN_REDUCTION_V#_", "> 0"}, applyIfPlatform={}, applyIfPlatformOr={}, failOn={}, applyIfOr={}, applyIfCPUFeatureAnd={}, applyIf={"SuperWordReductions", "true"}, applyIfCPUFeature={}, applyIfAnd={}, applyIfNot={})"
     > Phase "PrintIdeal":
       - counts: Graph contains wrong number of nodes:
         * Constraint 1: "(\\d+(\\s){2}(MinReductionV.*)+(\\s){2}===.*)"
           - Failed comparison: [found] 0 > 0 [given]
           - No nodes matched!

>>> Check stdout for compilation output of the failed methods


  #############################################################
   - To only run the failed tests use -DTest, -DExclude,
     and/or -DScenarios.
   - To also get the standard output of the test VM run with
     -DReportStdout=true or for even more fine-grained logging
     use -DVerbose=true.
  #############################################################


compiler.lib.ir_framework.driver.irmatching.IRViolationException: There were one or multiple IR rule failures. Please check stderr for more information.
	at compiler.lib.ir_framework.driver.irmatching.IRMatcher.reportFailures(IRMatcher.java:61)
	at compiler.lib.ir_framework.driver.irmatching.IRMatcher.match(IRMatcher.java:49)
	at compiler.lib.ir_framework.TestFramework.runTestVM(TestFramework.java:754)
	at compiler.lib.ir_framework.TestFramework.start(TestFramework.java:719)
	at compiler.lib.ir_framework.TestFramework.start(TestFramework.java:339)
	at compiler.lib.ir_framework.TestFramework.run(TestFramework.java:223)
	at compiler.lib.ir_framework.TestFramework.run(TestFramework.java:212)
	at compiler.c2.irTests.TestIfMinMax.main(TestIfMinMax.java:42)
	at java.base/jdk.internal.reflect.DirectMethodHandleAccessor.invoke(DirectMethodHandleAccessor.java:103)
	at java.base/java.lang.reflect.Method.invoke(Method.java:580)
	at com.sun.javatest.regtest.agent.MainActionHelper$AgentVMRunnable.run(MainActionHelper.java:333)
	at java.base/java.lang.Thread.run(Thread.java:1575)

JavaTest Message: Test threw exception: compiler.lib.ir_framework.driver.irmatching.IRViolationException
JavaTest Message: shutting down test

result: Failed. Execution failed: `main' threw exception: compiler.lib.ir_framework.driver.irmatching.IRViolationException: There were one or multiple IR rule failures. Please check stderr for more information.
Comments
Changeset: 438e6431 Author: Jasmine Karthikeyan <jkarthikeyan@openjdk.org> Committer: Tobias Hartmann <thartmann@openjdk.org> Date: 2024-04-24 05:22:51 +0000 URL: https://git.openjdk.org/jdk/commit/438e64310dc186d05de758103df1ea5504dcf33e
24-04-2024

A pull request was submitted for review. URL: https://git.openjdk.org/jdk/pull/18734 Date: 2024-04-11 01:38:28 +0000
11-04-2024

Great, thanks for confirming.
05-04-2024

Yep, if I set the first array element to Integer.MIN_VALUE I can reliably reproduce the failure. The condition will only be true for the first element and false afterwards, so the probability will be 1/512 (the length of the array) = ~0.002 and it won't CMove.
04-04-2024

That makes sense to me. Just to double-check, where you able to reproduce the failure by picking values that produce a low probability?
04-04-2024

Looking at the log, I think my assumption was correct. There are a bunch of IfNodes with P=0.009912, which is just shy of the threshold required to turn the if into a CMove (0.01). I think a fix for this would be to insert some manually picked values in the array before the random values, to ensure that the probability is at always above 0.01 or below 0.99.
04-04-2024

Thanks for taking a look! I attached the relevant part of the log.
03-04-2024

Thanks for the ping on this! I've tried replicating the bug with the seed on my linux-x64 machine, but I wasn't able to reproduce it. My assumption is that the IfNode's probability is too small to turn into a CMove and then a Min, so vectorization doesn't occur. I can try making the IR test more similar to MinMaxRed_Int, which also tests reductions. Does the log have the ideal node printout? I think that can help to confirm if that's what's going on. Thanks!
02-04-2024

The test is also missing the @randomized tag.
02-04-2024

ILW = Test fails due to unexpected C2 IR (test bug), intermittent with single test, no workaround = MLH = P4
02-04-2024

[~jkarthikeyan], could you please have a look?
02-04-2024

Failure is intermittent because the test uses randomization: For random generator using seed: 3591069654908203460 To re-run test with same seed value please add "-Djdk.test.lib.random.seed=3591069654908203460" to command line.
02-04-2024

The following bug is for the same test: JDK-8329355 Test compiler/c2/irTests/TestIfMinMax.java fails on RISC-V but it's fix appears to be very RISC-V specific.
02-04-2024