C2: Missed Ideal() optimization opportunities in PhaseIterGVN with AndL and URShiftL

XMLWordPrintable

      The attached Java Fuzzer test fails due to missing optimization opportunities with AndL and URShiftL:

      $ java -XX:CompileCommand=compileonly,Test::mainTest -XX:-TieredCompilation -Xbatch -XX:RepeatCompilation=100 -XX:+StressIGVN -XX:VerifyIterativeGVN=1110 Test.java
      $ java -XX:CompileCommand=compileonly,*Reduced*::test -XX:-TieredCompilation -Xbatch -XX:RepeatCompilation=100 -XX:+StressIGVN -XX:VerifyIterativeGVN=1110 Reduced.java

      #
      # A fatal error has been detected by the Java Runtime Environment:
      #
      # Internal Error (/System/Volumes/Data/mesos/work_dir/slaves/da1065b5-7b94-4f0d-85e9-a3a252b9a32e-S16414/frameworks/1735e8a2-a1db-478c-8104-60c8b0af87dd-0196/executors/5f4b6d90-3aea-4769-8636-a4b1ae7e9821/runs/22fcf67f-f610-411e-8f1a-8bc20f09e801/workspace/open/src/hotspot/share/opto/phaseX.hpp:285), pid=94958, tid=28163
      # assert(t != nullptr) failed: must set before get
      #
      # JRE version: Java(TM) SE Runtime Environment (26.0) (fastdebug build 26-internal-2025-11-26-2132223.patricio.chilano.mateo.random2)
      # Java VM: Java HotSpot(TM) 64-Bit Server VM (fastdebug 26-internal-2025-11-26-2132223.patricio.chilano.mateo.random2, mixed mode, sharing, compressed oops, compressed class ptrs, g1 gc, bsd-aarch64)
      ................
      Command Line: -Xmx1G -XX:+IgnoreUnrecognizedVMOptions -XX:CompileCommand=quiet -XX:CompileCommand=compileonly,*Test*::* -XX:-TieredCompilation -XX:+UnlockDiagnosticVMOptions -XX:StressSeed=1243943119 -Xbatch -XX:+UnlockDiagnosticVMOptions -XX:+StressLCM -XX:+StressGCM -XX:+StressIGVN -XX:+StressCCP -XX:+StressMacroExpansion -XX:+StressLoopPeeling -XX:+UnlockExperimentalVMOptions -XX:PerMethodSpecTrapLimit=0 -XX:PerMethodTrapLimit=0 -XX:+VerifyLoopOptimizations -XX:VerifyIterativeGVN=1110 -XX:MaxRAMPercentage=6.25 -Dtest.boot.jdk=/System/Volumes/Data/mesos/work_dir/jib-master/install/jdk/25/37/bundles/macos-aarch64/jdk-25_macos-aarch64_bin.tar.gz/jdk-25.jdk/Contents/Home -Djava.io.tmpdir=/System/Volumes/Data/mesos/work_dir/slaves/526fbd26-20de-495c-9a19-a04adc16f7d1-S34927/frameworks/1735e8a2-a1db-478c-8104-60c8b0af87dd-0196/executors/b4d82e73-c71b-4a2b-8a1c-c8eaa85145cf/runs/c8637973-f412-4843-af2c-fc79b30b405c/testoutput/test-support/jtreg_closed_test_hotspot_jtreg_applications_javafuzzer_MediumTest_java/tmp Test
      ................
      Current CompileTask:
      C2:872 39 !b Test::mainTest (617 bytes)

      Stack: [0x0000000170d08000,0x0000000170f0b000], sp=0x0000000170f06e50, free space=2043k
      Native frames: (J=compiled Java code, j=interpreted, Vv=VM code, C=native code)
      V [libjvm.dylib+0x127168c] VMError::report(outputStream*, bool)+0x1b68 (phaseX.hpp:285)
      V [libjvm.dylib+0x1274f88] VMError::report_and_die(int, char const*, char const*, char*, Thread*, unsigned char*, void const*, void const*, char const*, int, unsigned long)+0x55c
      V [libjvm.dylib+0x5e7674] print_error_for_unit_test(char const*, char const*, char*)+0x0
      V [libjvm.dylib+0xf595f0] PhaseIterGVN::verify_Value_for(Node*)+0x41c
      V [libjvm.dylib+0xf58700] PhaseIterGVN::verify_optimize()+0x25c
      V [libjvm.dylib+0xf5905c] PhaseIterGVN::optimize()+0x358
      V [libjvm.dylib+0x537cb4] Compile::Optimize()+0x228
      V [libjvm.dylib+0x53666c] Compile::Compile(ciEnv*, ciMethod*, int, Options, DirectiveSet*)+0x1578
      V [libjvm.dylib+0x3f38dc] C2Compiler::compile_method(ciEnv*, ciMethod*, int, bool, DirectiveSet*)+0x204
      V [libjvm.dylib+0x557fc8] CompileBroker::invoke_compiler_on_method(CompileTask*)+0x98c
      V [libjvm.dylib+0x5572c8] CompileBroker::compiler_thread_loop()+0x3cc
      V [libjvm.dylib+0x9519fc] JavaThread::thread_main_inner()+0x1f8
      V [libjvm.dylib+0x11b1374] Thread::call_run()+0xf0
      V [libjvm.dylib+0xf005dc] thread_native_entry(Thread*)+0x138
      C [libsystem_pthread.dylib+0x6c0c] _pthread_start+0x88

        1. FuzzerUtils.java
          13 kB
          Christian Hagedorn
        2. hs_err_pid94958.log
          77 kB
          Christian Hagedorn
        3. Reduced.java
          0.4 kB
          Christian Hagedorn
        4. Test.java
          7 kB
          Christian Hagedorn

            Assignee:
            Unassigned
            Reporter:
            Christian Hagedorn
            Votes:
            0 Vote for this issue
            Watchers:
            3 Start watching this issue

              Created:
              Updated: