C2: Missed Ideal optimization opportunity with AndL and URShiftL

XMLWordPrintable

    • Fix Understood

      The following Java Fuzzer test fails when run with -XX:VerifyIterativeGVN=1110:

      To reproduce:
      $ java -XX:CompileCommand=compileonly,*Test*::* -XX:-TieredCompilation -Xbatch -XX:VerifyIterativeGVN=1110 Test.java
      $ java -XX:CompileCommand=compileonly,*Reduced*::* -XX:-TieredCompilation -Xbatch -XX:VerifyIterativeGVN=1110 Reduced.java

      Output:
      Missed Ideal optimization (can_reshape=false):
      The node was replaced by Ideal.
      Old node:
      dist dump
      ---------------------------------------------
         1 440 ConI === 0 [[ 242 478 599 ]] #int:7
         1 479 AndL === _ 480 592 [[ 478 ]] !orig=235 !jvms: Test_2461::vMeth2 @ bci:105 (line 51)
         0 478 URShiftL === _ 479 440 [[ 464 382 ]] !orig=242 !jvms: Test_2461::vMeth2 @ bci:118 (line 53)
      The result after Ideal:
      dist dump
      ---------------------------------------------
         1 434 ConL === 0 [[ 600 ]] #long:-1
         1 599 URShiftL === _ 480 440 [[ 600 ]]
         0 600 AndL === _ 599 434 [[ ]]


      Missed Ideal optimization (can_reshape=true):
      The node was replaced by Ideal.
      Old node:
      dist dump
      ---------------------------------------------
         1 440 ConI === 0 [[ 242 478 599 ]] #int:7
         1 479 AndL === _ 480 592 [[ 478 ]] !orig=235 !jvms: Test_2461::vMeth2 @ bci:105 (line 51)
         0 478 URShiftL === _ 479 440 [[ 464 382 ]] !orig=242 !jvms: Test_2461::vMeth2 @ bci:118 (line 53)
      The result after Ideal:
      dist dump
      ---------------------------------------------
         1 434 ConL === 0 [[ 600 602 ]] #long:-1
         1 599 URShiftL === _ 480 440 [[ 600 602 ]] !orig=[601]
         0 602 AndL === _ 599 434 [[ ]]

      #
      # A fatal error has been detected by the Java Runtime Environment:
      #
      # Internal Error (/opt/mach5/mesos/work_dir/slaves/526fbd26-20de-495c-9a19-a04adc16f7d1-S26825/frameworks/1735e8a2-a1db-478c-8104-60c8b0af87dd-0196/executors/93dda7e9-4011-4f94-8344-ed81ed00c1d2/runs/0742333f-9271-480c-9e35-71e1a3833fc0/workspace/open/src/hotspot/share/opto/phaseX.hpp:285), pid=168698, tid=168716
      # assert(t != nullptr) failed: must set before get
      #
      # JRE version: Java(TM) SE Runtime Environment (26.0) (fastdebug build 26-internal-2025-11-08-1921047.albert.m.yang.clion-jdk)
      # Java VM: Java HotSpot(TM) 64-Bit Server VM (fastdebug 26-internal-2025-11-08-1921047.albert.m.yang.clion-jdk, mixed mode, sharing, compressed oops, compressed class ptrs, g1 gc, linux-aarch64)
      # Problematic frame:
      # V [libjvm.so+0x15bf5a0] PhaseValues::type(Node const*) const [clone .isra.0]+0x80
      ................
      Command Line: -Xmx1G -XX:+IgnoreUnrecognizedVMOptions -XX:CompileCommand=quiet -XX:CompileCommand=compileonly,*Test*::* -XX:-TieredCompilation -Xbatch -XX:+UnlockDiagnosticVMOptions -XX:StressSeed=74065881 -XX:+UnlockDiagnosticVMOptions -XX:+StressLCM -XX:+StressGCM -XX:+StressIGVN -XX:+StressCCP -XX:+StressMacroExpansion -XX:+StressLoopPeeling -XX:+VerifyLoopOptimizations -XX:VerifyIterativeGVN=1110 Test_2461
      ..............
      Current CompileTask:
      C2:166 4 b Test_2461::vMeth2 (186 bytes)

      Stack: [0x0000ffff855ca000,0x0000ffff857c8000], sp=0x0000ffff857c24b0, free space=2017k
      Native frames: (J=compiled Java code, j=interpreted, Vv=VM code, C=native code)
      V [libjvm.so+0x15bf5a0] PhaseValues::type(Node const*) const [clone .isra.0]+0x80 (phaseX.hpp:285)
      V [libjvm.so+0x15cfc98] PhaseIterGVN::verify_Value_for(Node*)+0x38 (phaseX.cpp:1138)
      V [libjvm.so+0x15d1890] PhaseIterGVN::verify_optimize()+0x64c (phaseX.cpp:1087)
      V [libjvm.so+0x15d2550] PhaseIterGVN::optimize()+0x290 (phaseX.cpp:1069)
      V [libjvm.so+0x9e8e5c] PhaseIdealLoop::optimize(PhaseIterGVN&, LoopOptsMode)+0x49c (loopnode.hpp:1344)
      V [libjvm.so+0x9e1208] Compile::optimize_loops(PhaseIterGVN&, LoopOptsMode)+0x88 (compile.cpp:2262)
      V [libjvm.so+0x9e3698] Compile::Optimize()+0xa70 (compile.cpp:2511)
      V [libjvm.so+0x9e5c70] Compile::Compile(ciEnv*, ciMethod*, int, Options, DirectiveSet*)+0x16a4 (compile.cpp:860)
      V [libjvm.so+0x812d20] C2Compiler::compile_method(ciEnv*, ciMethod*, int, bool, DirectiveSet*)+0x2dc (c2compiler.cpp:147)
      V [libjvm.so+0x9f49cc] CompileBroker::invoke_compiler_on_method(CompileTask*)+0xb08 (compileBroker.cpp:2345)
      V [libjvm.so+0x9f5904] CompileBroker::compiler_thread_loop()+0x644 (compileBroker.cpp:1989)
      V [libjvm.so+0xefb208] JavaThread::thread_main_inner()+0x108 (javaThread.cpp:776)
      V [libjvm.so+0x18724bc] Thread::call_run()+0xac (thread.cpp:242)
      V [libjvm.so+0x154440c] thread_native_entry(Thread*)+0x11c (os_linux.cpp:877)
      C [libc.so.6+0x80b50] start_thread+0x300

        1. hs_err_pid168698.log
          71 kB
        2. Reduced.java
          0.5 kB
        3. Test.java
          9 kB

            Assignee:
            BenoƮt Maillard
            Reporter:
            Christian Hagedorn
            Votes:
            0 Vote for this issue
            Watchers:
            4 Start watching this issue

              Created:
              Updated: