RFR: 8350896: Integer/Long.compress gets wrong type from CompressBitsNode::Value [v14]

Jatin Bhateja jbhateja at openjdk.org
Wed Jul 16 06:33:47 UTC 2025


On Tue, 15 Jul 2025 16:04:47 GMT, Jatin Bhateja <jbhateja at openjdk.org> wrote:

> > With the latest version, I see this failure:
> > ```
> > java/lang/CompressExpandTest.java
> > -Xcomp -ea -esa -XX:CompileThreshold=100 -XX:+UnlockExperimentalVMOptions -server -XX:+TieredCompilation -XX:+DeoptimizeALot
> > 
> >  870  Phi  === 820 227 872  [[ 339 339 120 282 334 224 338 338 119 119 337 337 336 336 340 120 335 335 432 275 283 224 340 334 ]]  #int !orig=[98] !jvms: Assert::assertEquals @ bci:1 (line 797) Assert::assertEquals @ bci:3 (line 807) AbstractCompressExpandTest::assertContiguousMask @ bci:13 (line 356) AbstractCompressExpandTest::testContiguousMasksInt @ bci:48 (line 251)
> >  917  LoadI  === 916 218 219  [[ 336 336 331 119 119 339 339 432 275 337 337 338 338 224 224 340 340 120 120 342 330 118 117 116 115 341 343 114 113 112 111 344 121 110 333 332 335 335 282 439 109 329 328 334 334 222 327 122 254 369 ]]  @int[int:>=0] (java/lang/Cloneable,java/io/Serializable):exact+any *, idx=7; #int (does not depend only on test, unknown control) !orig=[86] !jvms: AbstractCompressExpandTest::testContiguousMasksInt @ bci:39 (line 250)
> >  282  ExpandBits  === _ 917 870  [[ 120 120 340 340 224 224 338 338 736 338 339 339 380 ]]  #int !jvms: CompressExpandTest::actualExpand @ bci:2 (line 40) AbstractCompressExpandTest::assertContiguousMask @ bci:17 (line 265) AbstractCompressExpandTest::testContiguousMasksInt @ bci:92 (line 256)
> > told = bool
> > tnew = int:1..2
> > #
> > # A fatal error has been detected by the Java Runtime Environment:
> > #
> > #  Internal Error (/workspace/open/src/hotspot/share/opto/phaseX.cpp:2731), pid=6038, tid=6057
> > #  fatal error: Not monotonic
> > #
> > # JRE version: Java(TM) SE Runtime Environment (26.0) (fastdebug build 26-internal-2025-07-15-0649374.tobias.hartmann.jdk4)
> > # Java VM: Java HotSpot(TM) 64-Bit Server VM (fastdebug 26-internal-2025-07-15-0649374.tobias.hartmann.jdk4, compiled mode, tiered, compressed oops, compressed class ptrs, g1 gc, linux-amd64)
> > # Problematic frame:
> > # V  [libjvm.so+0x1828409]  PhaseCCP::verify_type(Node*, Type const*, Type const*)+0x169
> > #26314 
> > ```
> > 
> > 
> >     
> >       
> >     
> > 
> >       
> >     
> > 
> >     
> >   
> > Also happens with a few other configurations/flags.
> 
> Thanks @TobiHartmann , looking at this.

Hi @TobiHartmann ,

I have been able to reproduce this issue with a smaller test, in my last commit, incorrectly constrained the lower bound of the result for unknown mask, due to the OCA limitation will create a new PR with an updated patch.



public class expand_bits {
    public static long micro(long src, long mask) {
        long res = 0;
        mask = Math.max(0, Math.min(1, mask));
        // mask = {lo:0, hi:1}
        for (int i = 0; i < 5; i++) {
            if (i == 4) {
                mask = 3;
            } else if (i == 2) {
                mask = 7;
            }
            // meet(3, 7) = (lo:3, hi:7)
            res += Long.expand(src, mask);

        }
        return res;
    }

    public static void main(String [] args) {
        long res = 0;
        for (int i = 0; i < 100000; i++) {
            res += micro(i, i + 10);
        }
        System.out.println("[res] " + res);
    }
}


With java -Xcomp  -Xbatch -XX:-TieredCompilation -XX:CompileOnly=expand_bits::micro -XX:+TracePhaseCCP -cp . expand_bits


 158  Phi  === 152 120 107  [[ 151 157 161 ]]  #long:3..7 !orig=[117] !jvms: expand_bits::micro @ bci:38 (line 11)
  10  Parm  === 3  [[ 157 121 78 67 45 56 151 ]] Parm0: long !jvms: expand_bits::micro @ bci:-1 (line 5)
 157  ExpandBits  === _ 10 158  [[ 156 ]]  #long:3..7:www !orig=121 !jvms: expand_bits::micro @ bci:49 (line 16)
told = long:0..7:www
tnew = long:3..7:www
#
# A fatal error has been detected by the Java Runtime Environment:
#
#  Internal Error (/mnt/c/GitHub/jdk/src/hotspot/share/opto/phaseX.cpp:1806), pid=97823, tid=97837
#  fatal error: Not monotonic

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

PR Comment: https://git.openjdk.org/jdk/pull/23947#issuecomment-3077054087


More information about the hotspot-compiler-dev mailing list