-
Enhancement
-
Resolution: Fixed
-
P4
-
11, 15
-
b23
-
generic
-
generic
Issue | Fix Version | Assignee | Priority | Status | Resolution | Resolved In Build |
---|---|---|---|---|---|---|
JDK-8264969 | 11.0.12 | Yang Zhang | P4 | Resolved | Fixed | b01 |
For java code "(i >> 31) >>> 31", it can be optimized to "i >>> 31".
AArch64 has implemented this in back-end match rules, while AMD64
hasn’t.
Indeed, this pattern can be optimized in mid-end by adding some simple
transformations. Besides, "0 - (i >> 31)" could also be optimized to
"i >>> 31".
This patch adds two conversions:
1. URShiftINode: (i >> 31) >>> 31 ==> i >>> 31
+------+ +----------+
| Parm | | ConI(31) |
+------+ +----------+
| / |
| / |
| / |
+---------+ |
| RShiftI | |
+---------+ |
\ |
\ |
\ |
+----------+
| URShiftI |
+----------+
2. SubINode: 0 - (i >> 31) ==> i >>> 31
+------+ +----------+
| Parm | | ConI(31) |
+------+ +----------+
\ |
\ |
\ |
\ |
+---------+ +---------+
| ConI(0) | | RShiftI |
+---------+ +---------+
\ |
\ |
\ |
+------+
| SubI |
+------+
With this patch, these two graghs above both can be optimized to below:
+------+ +----------+
| Parm | | ConI(31) |
+------+ +----------+
| /
| /
| /
| /
+----------+
| URShiftI |
+----------+
AArch64 has implemented this in back-end match rules, while AMD64
hasn’t.
Indeed, this pattern can be optimized in mid-end by adding some simple
transformations. Besides, "0 - (i >> 31)" could also be optimized to
"i >>> 31".
This patch adds two conversions:
1. URShiftINode: (i >> 31) >>> 31 ==> i >>> 31
+------+ +----------+
| Parm | | ConI(31) |
+------+ +----------+
| / |
| / |
| / |
+---------+ |
| RShiftI | |
+---------+ |
\ |
\ |
\ |
+----------+
| URShiftI |
+----------+
2. SubINode: 0 - (i >> 31) ==> i >>> 31
+------+ +----------+
| Parm | | ConI(31) |
+------+ +----------+
\ |
\ |
\ |
\ |
+---------+ +---------+
| ConI(0) | | RShiftI |
+---------+ +---------+
\ |
\ |
\ |
+------+
| SubI |
+------+
With this patch, these two graghs above both can be optimized to below:
+------+ +----------+
| Parm | | ConI(31) |
+------+ +----------+
| /
| /
| /
| /
+----------+
| URShiftI |
+----------+
- backported by
-
JDK-8264969 Better implementation for signed extract
- Resolved