-
Enhancement
-
Resolution: Unresolved
-
P4
-
21
Improve reasoning at branches so that the compiler can be more efficient at eliminating conditional jumps. This helps eliminate branches in a more rigorous manner, such as in these complex cases:
- x < y and y < z -> x < z
- x < z and y < z -> Phi(x, y) < z
- 0 < x < y and 0 < x + k < y with k > 0 -> 0 < x + i < y for all 0 <= i <= k
A possible approach is to use a truth table, representing the relationships between the variables in each control node, this table can be filled in walking down the dominator path, and be used to eliminate conditional branches which cannot be inferred from constant bounds only. This concept can be found at [Go's prove pass](https://github.com/golang/go/blob/master/src/cmd/compile/internal/ssa/prove.go). I think this can be done pessimistically and optimistically along with IterGVN if the cost seems reasonable.
- x < y and y < z -> x < z
- x < z and y < z -> Phi(x, y) < z
- 0 < x < y and 0 < x + k < y with k > 0 -> 0 < x + i < y for all 0 <= i <= k
A possible approach is to use a truth table, representing the relationships between the variables in each control node, this table can be filled in walking down the dominator path, and be used to eliminate conditional branches which cannot be inferred from constant bounds only. This concept can be found at [Go's prove pass](https://github.com/golang/go/blob/master/src/cmd/compile/internal/ssa/prove.go). I think this can be done pessimistically and optimistically along with IterGVN if the cost seems reasonable.
- relates to
-
JDK-8275202 C2: optimize out more redundant conditions
-
- Open
-
-
JDK-8298282 Fail to elide bound checks in loop with the same entry condition
-
- Open
-