JDK-6404000 : Recognize idiom for unsigned comparison
  • Type: Enhancement
  • Component: hotspot
  • Sub-Component: compiler
  • Affected Version: 5.0u4,9,10
  • Priority: P4
  • Status: Closed
  • Resolution: Won't Fix
  • OS: generic
  • CPU: sparc
  • Submitted: 2006-03-24
  • Updated: 2023-10-05
  • Resolved: 2020-06-30
Related Reports
Relates :  
Description
Java does not have primitives for unsigned integers.

Comparisons of unsigned quantities can be achieved by adding
MIN_VALUE to both sides of a signed inequality.  For example:

public class ULong {
    private long value;
    public boolean gt(long ulong) {
        return value + Long.MIN_VALUE > ulong + Long.MIN_VALUE;
    }
}

When the machine architecture supports unsigned comparisions, as is
the case for SPARC, the compiler can recognize this idiom and utilize
the unsigned comparison instructions.

Note that the use of + in the method gt() above can correctly be replaced
with either - or ^.  (The desired effect is the flipping of the sign bit.)

Comments
SPARC port was removed in JDK 15: JDK-8244224
30-06-2020

I'm not sure if this enhancement applies to C1 as well. Added label to be on the safe side.
16-02-2017