Remove purely informative definitions from the graph.
authormmassi@chromium.org <mmassi@chromium.org@ce2b1a6d-e550-0410-aec6-3dcde31c8c00>
Tue, 19 Feb 2013 16:32:02 +0000 (16:32 +0000)
committermmassi@chromium.org <mmassi@chromium.org@ce2b1a6d-e550-0410-aec6-3dcde31c8c00>
Tue, 19 Feb 2013 16:32:02 +0000 (16:32 +0000)
Review URL: https://codereview.chromium.org/12282033

git-svn-id: http://v8.googlecode.com/svn/branches/bleeding_edge@13696 ce2b1a6d-e550-0410-aec6-3dcde31c8c00

src/hydrogen-instructions.h
src/hydrogen.cc

index 2e7e374..829567a 100644 (file)
@@ -819,6 +819,11 @@ class HValue: public ZoneObject {
                                      : NULL;
   }
 
+  // A purely informative definition is an idef that will not emit code and
+  // should therefore be removed from the graph in the RestoreActualValues
+  // phase (so that live ranges will be shorter).
+  virtual bool IsPurelyInformativeDefinition() { return false; }
+
   // This method must always return the original HValue SSA definition
   // (regardless of any iDef of this value).
   HValue* ActualValue() {
@@ -1286,6 +1291,7 @@ class HNumericConstraint : public HTemplateInstruction<2> {
   NumericRelation relation() { return relation_; }
 
   virtual int RedefinedOperandIndex() { return 0; }
+  virtual bool IsPurelyInformativeDefinition() { return true; }
 
   virtual Representation RequiredInputRepresentation(int index) {
     return representation();
@@ -3363,6 +3369,7 @@ class HBoundsCheck: public HTemplateInstruction<2> {
   HValue* length() { return OperandAt(1); }
 
   virtual int RedefinedOperandIndex() { return 0; }
+  virtual bool IsPurelyInformativeDefinition() { return skip_check(); }
   virtual void AddInformativeDefinitions();
 
   DECLARE_CONCRETE_INSTRUCTION(BoundsCheck)
index ed21567..62fa571 100644 (file)
@@ -4384,7 +4384,12 @@ void HGraph::RestoreActualValues() {
         instruction != NULL;
         instruction = instruction->next()) {
       if (instruction->ActualValue() != instruction) {
-        instruction->ReplaceAllUsesWith(instruction->ActualValue());
+        ASSERT(instruction->IsInformativeDefinition());
+        if (instruction->IsPurelyInformativeDefinition()) {
+          instruction->DeleteAndReplaceWith(instruction->RedefinedOperand());
+        } else {
+          instruction->ReplaceAllUsesWith(instruction->ActualValue());
+        }
       }
     }
   }