Uploaded image for project: 'JDK'
  1. JDK
  2. JDK-8317521

Enhance detection of integral unsigned comparisons

XMLWordPrintable

    • Icon: Enhancement Enhancement
    • Resolution: Unresolved
    • Icon: P4 P4
    • tbd
    • 22
    • hotspot

      When Java code needs to perform an "unsigned int" comparison, the conventional ways to do that is to use a pattern like `(MIN_VALUE ^ x) < (MIN_VALUE ^ y)` or `(MIN_VALUE + x) < (MIN_VALUE + y)` (or any combination permitted by commutativity).

      Currently, the first pattern is translated by C2 exactly as written in Java, using two ^ and a signed < instructions. The second, however, is recognized as an "unsigned comparison pattern" and translated directly to an unsigned comparison, removing the two + operations.

      Since both pattern are used by Java programmers when they need to express unsigned comparisons, the first pattern should be recognized as an "unsigned comparison pattern" as well.

      Similarly for the `long` case.

            Unassigned Unassigned
            rgiulietti Raffaello Giulietti
            Votes:
            0 Vote for this issue
            Watchers:
            5 Start watching this issue

              Created:
              Updated: