8182475: C2: allow vectorization of HeapByteBuffer.putInt loops
authorroland
Thu, 27 Jul 2017 17:47:57 -0700
changeset 46728 a1bee305515d
parent 46727 6e4a84748e2c
child 46729 c62d2e8b2728
8182475: C2: allow vectorization of HeapByteBuffer.putInt loops Reviewed-by: kvn
hotspot/src/share/vm/opto/superword.cpp
--- a/hotspot/src/share/vm/opto/superword.cpp	Thu Jul 27 18:06:41 2017 -0400
+++ b/hotspot/src/share/vm/opto/superword.cpp	Thu Jul 27 17:47:57 2017 -0700
@@ -3199,7 +3199,15 @@
   if (align_to_ref_p.invar() != NULL) {
     // incorporate any extra invariant piece producing (offset +/- invar) >>> log2(elt)
     Node* log2_elt = _igvn.intcon(exact_log2(elt_size));
-    Node* aref     = new URShiftINode(align_to_ref_p.invar(), log2_elt);
+    Node* invar = align_to_ref_p.invar();
+    if (_igvn.type(invar)->isa_long()) {
+      // Computations are done % (vector width/element size) so it's
+      // safe to simply convert invar to an int and loose the upper 32
+      // bit half.
+      invar = new ConvL2INode(invar);
+      _igvn.register_new_node_with_optimizer(invar);
+    }
+    Node* aref = new URShiftINode(invar, log2_elt);
     _igvn.register_new_node_with_optimizer(aref);
     _phase->set_ctrl(aref, pre_ctrl);
     if (align_to_ref_p.negate_invar()) {
@@ -3644,12 +3652,10 @@
         n = n->in(1);
       }
     }
-    if (n->bottom_type()->isa_int()) {
-      _negate_invar = negate;
-      _invar = n;
-      NOT_PRODUCT(_tracer.offset_plus_k_10(n, _invar, _negate_invar, _offset);)
-      return true;
-    }
+    _negate_invar = negate;
+    _invar = n;
+    NOT_PRODUCT(_tracer.offset_plus_k_10(n, _invar, _negate_invar, _offset);)
+    return true;
   }
 
   NOT_PRODUCT(_tracer.offset_plus_k_11(n);)