-
Type:
Enhancement
-
Resolution: Fixed
-
Priority:
P5
-
Affects Version/s: 23
-
Component/s: hotspot
-
b19
-
generic
-
generic
Following the ideas of https://bugs.openjdk.org/browse/JDK-8250808, we can reassociate expressions involving Cmps and Add/Subs
```
// Apply the same transformations to == and !=
inv1 == (x + inv2) => ( inv1 - inv2 ) == x
inv1 == (x - inv2) => ( inv1 + inv2 ) == x
inv1 == (inv2 - x) => (-inv1 + inv2 ) == x
```
This can only be done for `==` and `!=`, or else we can break comparisons if there are overflows.
```
// Apply the same transformations to == and !=
inv1 == (x + inv2) => ( inv1 - inv2 ) == x
inv1 == (x - inv2) => ( inv1 + inv2 ) == x
inv1 == (inv2 - x) => (-inv1 + inv2 ) == x
```
This can only be done for `==` and `!=`, or else we can break comparisons if there are overflows.
- relates to
-
JDK-8250808 Re-associate loop invariants with other associative operations
-
- Resolved
-