-
Enhancement
-
Resolution: Unresolved
-
P4
-
22
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.
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.
- relates to
-
JDK-8276162 Optimise unsigned comparison pattern
- Resolved
-
JDK-6404000 Recognize idiom for unsigned comparison
- Closed