RFR(S):8242429:Better implementation for signed extract
Eric Liu
eric.c.liu at arm.com
Thu Apr 9 12:57:32 UTC 2020
Hi,
This is a small enhancement for C2 compiler.
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 |
+----------+
This patch solved the same issue for long type and also removed the
relevant match rules in "aarch64.ad" which become useless now.
JBS: https://bugs.openjdk.java.net/browse/JDK-8242429
Webrev: http://cr.openjdk.java.net/~yzhang/ericliu/8242429/webrev.00/
[Tests]
Jtreg hotspot::hotspot_all_no_apps, jdk::jdk_core and langtools::tier1.
No new failure found.
--
Thanks,
Eric
More information about the hotspot-compiler-dev
mailing list