view ppc_patches/0204_opto-explicit_specification_of_rematerialization_in_ad_file.patch @ 4881:edf2bb42e70f

Recent changes to patch queue
author goetz
date Fri, 28 Jun 2013 16:31:09 +0200
parents df79d76c17ab
children 9a2cb37c4d01
line wrap: on
line source
# HG changeset patch
# Parent 898e495e7e960edbe3b9795e1a0c83699805bcdd
opto: explicit specification of rematerialization in ad file.

Introduce attributes "ins_cannot_rematerialize" and
"ins_should_rematerialize" to adl which allows/forbids
rematerialization.
If ins_cannot_rematerialize is set, the instruction will never
rematerialize.
If ins_should_rematerialize is set, adlc generates a rule for
the node that allows rematerialization.
See also MachNode::rematerialize().

This fixes a problem with rematerialization on PPC: constants
are rematerialized in a way that extends the live range of the
MachConstantBaseNode. This causes the assertion 'edge_from_to' in
Scheduling::verify_good_schedule() to fire.

diff -r 898e495e7e96 src/share/vm/adlc/formssel.cpp
--- a/src/share/vm/adlc/formssel.cpp	Fri Jun 28 15:59:15 2013 +0200
+++ b/src/share/vm/adlc/formssel.cpp	Fri Jun 28 16:00:02 2013 +0200
@@ -549,6 +549,28 @@
     return false;
   }
 
+  // Enforce/prohibit rematerializations.
+  // - If an instruction is attributed with 'ins_cannot_rematerialize(true)'
+  //   then rematerialization of that instruction is prohibited and the
+  //   instruction's value will be spilled if necessary.
+  //   Causes that MachNode::rematerialize() returns false.
+  // - If an instruction is attributed with 'ins_should_rematerialize(true)'
+  //   then rematerialization should be enforced and a copy of the instruction
+  //   should be inserted if possible; rematerialization is not guaranteed.
+  //   note: this may result in rematerializations in front of every use.
+  //   (optional attribute)
+  //   Causes that MachNode::rematerialize() returns true.
+  Attribute *attr = _attribs;
+  while (attr != NULL) {
+    if (!strcmp(attr->_ident,"ins_cannot_rematerialize") && !strcmp(attr->_val, "true")) {
+      return false;
+    }
+    if (!strcmp(attr->_ident,"ins_should_rematerialize") && !strcmp(attr->_val, "true")) {
+      return true;
+    }
+    attr = (Attribute *)attr->_next;
+  }
+
   // Constants
   if( _components.count() == 1 && _components[0]->is(Component::USE_DEF) )
     rematerialize = true;
diff -r 898e495e7e96 src/share/vm/adlc/output_h.cpp
--- a/src/share/vm/adlc/output_h.cpp	Fri Jun 28 15:59:15 2013 +0200
+++ b/src/share/vm/adlc/output_h.cpp	Fri Jun 28 16:00:02 2013 +0200
@@ -1605,6 +1605,9 @@
     while (attr != NULL) {
       if (strcmp (attr->_ident,"ins_cost") &&
           strncmp(attr->_ident,"ins_field_", 10) != 0 &&
+          // Rematerialize attributes are used in formssel, no function needs to be generated.
+          strcmp (attr->_ident,"ins_cannot_rematerialize") != 0 &&
+          strcmp (attr->_ident,"ins_should_rematerialize") != 0 &&
           strcmp (attr->_ident,"ins_short_branch")) {
         fprintf(fp,"  virtual int            %s() const { return %s; }\n",
                 attr->_ident, attr->_val);