8154943: AArch64: redundant address computation instructions with vectorization
Summary: duplicated i2l nodes can be eliminated to optimize redundant address computations
Reviewed-by: kvn, dlong
--- a/hotspot/src/cpu/aarch64/vm/aarch64.ad Wed May 04 13:32:03 2016 -0700
+++ b/hotspot/src/cpu/aarch64/vm/aarch64.ad Fri Apr 29 17:24:16 2016 +0200
@@ -3566,6 +3566,8 @@
return FP_REG_mask();
}
+const bool Matcher::convi2l_type_required = false;
+
// helper for encoding java_to_runtime calls on sim
//
// this is needed to compute the extra arguments required when
--- a/hotspot/src/cpu/ppc/vm/ppc.ad Wed May 04 13:32:03 2016 -0700
+++ b/hotspot/src/cpu/ppc/vm/ppc.ad Fri Apr 29 17:24:16 2016 +0200
@@ -2313,6 +2313,8 @@
return RegMask();
}
+const bool Matcher::convi2l_type_required = true;
+
%}
//----------ENCODING BLOCK-----------------------------------------------------
--- a/hotspot/src/cpu/sparc/vm/sparc.ad Wed May 04 13:32:03 2016 -0700
+++ b/hotspot/src/cpu/sparc/vm/sparc.ad Fri Apr 29 17:24:16 2016 +0200
@@ -2133,6 +2133,8 @@
return L7_REGP_mask();
}
+const bool Matcher::convi2l_type_required = true;
+
%}
--- a/hotspot/src/cpu/x86/vm/x86.ad Wed May 04 13:32:03 2016 -0700
+++ b/hotspot/src/cpu/x86/vm/x86.ad Fri Apr 29 17:24:16 2016 +0200
@@ -1861,6 +1861,8 @@
return false;
}
+const bool Matcher::convi2l_type_required = true;
+
// Helper methods for MachSpillCopyNode::implementation().
static int vec_mov_helper(CodeBuffer *cbuf, bool do_size, int src_lo, int dst_lo,
int src_hi, int dst_hi, uint ireg, outputStream* st) {
--- a/hotspot/src/share/vm/opto/compile.cpp Wed May 04 13:32:03 2016 -0700
+++ b/hotspot/src/share/vm/opto/compile.cpp Fri Apr 29 17:24:16 2016 +0200
@@ -3263,6 +3263,43 @@
frc._tests.push(iff);
break;
}
+ case Op_ConvI2L: {
+ if (!Matcher::convi2l_type_required) {
+ // Code generation on some platforms doesn't need accurate
+ // ConvI2L types. Widening the type can help remove redundant
+ // address computations.
+ n->as_Type()->set_type(TypeLong::INT);
+ ResourceMark rm;
+ Node_List wq;
+ wq.push(n);
+ for (uint next = 0; next < wq.size(); next++) {
+ Node *m = wq.at(next);
+
+ for(;;) {
+ // Loop over all nodes with identical inputs edges as m
+ Node* k = m->find_similar(m->Opcode());
+ if (k == NULL) {
+ break;
+ }
+ // Push their uses so we get a chance to remove node made
+ // redundant
+ for (DUIterator_Fast imax, i = k->fast_outs(imax); i < imax; i++) {
+ Node* u = k->fast_out(i);
+ assert(!wq.contains(u), "shouldn't process one node several times");
+ if (u->Opcode() == Op_LShiftL ||
+ u->Opcode() == Op_AddL ||
+ u->Opcode() == Op_SubL ||
+ u->Opcode() == Op_AddP) {
+ wq.push(u);
+ }
+ }
+ // Replace all nodes with identical edges as m with m
+ k->subsume_by(m, this);
+ }
+ }
+ }
+ break;
+ }
default:
assert( !n->is_Call(), "" );
assert( !n->is_Mem(), "" );
--- a/hotspot/src/share/vm/opto/matcher.hpp Wed May 04 13:32:03 2016 -0700
+++ b/hotspot/src/share/vm/opto/matcher.hpp Fri Apr 29 17:24:16 2016 +0200
@@ -488,6 +488,9 @@
// ourselves.
static const bool need_masked_shift_count;
+ // Whether code generation need accurate ConvI2L types.
+ static const bool convi2l_type_required;
+
// This routine is run whenever a graph fails to match.
// If it returns, the compiler should bailout to interpreter without error.
// In non-product mode, SoftMatchFailure is false to detect non-canonical
--- a/hotspot/src/share/vm/opto/node.cpp Wed May 04 13:32:03 2016 -0700
+++ b/hotspot/src/share/vm/opto/node.cpp Fri Apr 29 17:24:16 2016 +0200
@@ -2297,7 +2297,8 @@
if (def && def->outcnt() >= 2) {
for (DUIterator_Fast dmax, i = def->fast_outs(dmax); i < dmax; i++) {
Node* use = def->fast_out(i);
- if (use->Opcode() == opc &&
+ if (use != this &&
+ use->Opcode() == opc &&
use->req() == req()) {
uint j;
for (j = 0; j < use->req(); j++) {