< prev index next >

src/share/vm/opto/node.cpp

Print this page




 888   // debug_only(destruct();)   // no reuse benefit expected
 889   if (edges_to_n == 0) {
 890     C->record_dead_node(_idx);
 891   }
 892   return edges_to_n;
 893 }
 894 
 895 //-----------------------------uncast---------------------------------------
 896 // %%% Temporary, until we sort out CheckCastPP vs. CastPP.
 897 // Strip away casting.  (It is depth-limited.)
 898 Node* Node::uncast() const {
 899   // Should be inline:
 900   //return is_ConstraintCast() ? uncast_helper(this) : (Node*) this;
 901   if (is_ConstraintCast())
 902     return uncast_helper(this);
 903   else
 904     return (Node*) this;
 905 }
 906 
 907 // Find out of current node that matches opcode.
 908 Node* Node::find_out_with(int opcode) {
 909   for (DUIterator_Fast imax, i = fast_outs(imax); i < imax; i++) {
 910     Node* use = fast_out(i);
 911     if (use->Opcode() == opcode) {
 912       return use;
 913     }
 914   }
 915   return NULL;
 916 }
 917 
 918 // Return true if the current node has an out that matches opcode.
 919 bool Node::has_out_with(int opcode) {
 920   return (find_out_with(opcode) != NULL);
 921 }
 922 
 923 // Return true if the current node has an out that matches any of the opcodes.
 924 bool Node::has_out_with(int opcode1, int opcode2, int opcode3, int opcode4) {
 925   for (DUIterator_Fast imax, i = fast_outs(imax); i < imax; i++) {
 926       int opcode = fast_out(i)->Opcode();
 927       if (opcode == opcode1 || opcode == opcode2 || opcode == opcode3 || opcode == opcode4) {
 928         return true;
 929       }
 930   }
 931   return false;
 932 }
 933 
 934 
 935 //---------------------------uncast_helper-------------------------------------
 936 Node* Node::uncast_helper(const Node* p) {
 937 #ifdef ASSERT
 938   uint depth_count = 0;
 939   const Node* orig_p = p;
 940 #endif
 941 
 942   while (true) {
 943 #ifdef ASSERT
 944     if (depth_count >= K) {
 945       orig_p->dump(4);
 946       if (p != orig_p)


1114 //    return new AddINode(shift, in(1));
1115 //
1116 // When making a Node for a constant use 'phase->makecon' or 'phase->intcon'.
1117 // These forms are faster than 'phase->transform(new ConNode())' and Do
1118 // The Right Thing with def-use info.
1119 //
1120 // You cannot bury the 'this' Node inside of a graph reshape.  If the reshaped
1121 // graph uses the 'this' Node it must be the root.  If you want a Node with
1122 // the same Opcode as the 'this' pointer use 'clone'.
1123 //
1124 Node *Node::Ideal(PhaseGVN *phase, bool can_reshape) {
1125   return NULL;                  // Default to being Ideal already
1126 }
1127 
1128 // Some nodes have specific Ideal subgraph transformations only if they are
1129 // unique users of specific nodes. Such nodes should be put on IGVN worklist
1130 // for the transformations to happen.
1131 bool Node::has_special_unique_user() const {
1132   assert(outcnt() == 1, "match only for unique out");
1133   Node* n = unique_out();
1134   int op  = Opcode();
1135   if (this->is_Store()) {
1136     // Condition for back-to-back stores folding.
1137     return n->Opcode() == op && n->in(MemNode::Memory) == this;
1138   } else if (this->is_Load()) {
1139     // Condition for removing an unused LoadNode from the MemBarAcquire precedence input
1140     return n->Opcode() == Op_MemBarAcquire;
1141   } else if (op == Op_AddL) {
1142     // Condition for convL2I(addL(x,y)) ==> addI(convL2I(x),convL2I(y))
1143     return n->Opcode() == Op_ConvL2I && n->in(1) == this;
1144   } else if (op == Op_SubI || op == Op_SubL) {
1145     // Condition for subI(x,subI(y,z)) ==> subI(addI(x,z),y)
1146     return n->Opcode() == op && n->in(2) == this;
1147   } else if (is_If() && (n->is_IfFalse() || n->is_IfTrue())) {
1148     // See IfProjNode::Identity()
1149     return true;
1150   }
1151   return false;
1152 };
1153 
1154 //--------------------------find_exact_control---------------------------------


2273 // value, if it appears (by local graph inspection) to be computed by a simple conditional.
2274 bool Node::is_iteratively_computed() {
2275   if (ideal_reg()) { // does operation have a result register?
2276     for (uint i = 1; i < req(); i++) {
2277       Node* n = in(i);
2278       if (n != NULL && n->is_Phi()) {
2279         for (uint j = 1; j < n->req(); j++) {
2280           if (n->in(j) == this) {
2281             return true;
2282           }
2283         }
2284       }
2285     }
2286   }
2287   return false;
2288 }
2289 
2290 //--------------------------find_similar------------------------------
2291 // Return a node with opcode "opc" and same inputs as "this" if one can
2292 // be found; Otherwise return NULL;
2293 Node* Node::find_similar(int opc) {
2294   if (req() >= 2) {
2295     Node* def = in(1);
2296     if (def && def->outcnt() >= 2) {
2297       for (DUIterator_Fast dmax, i = def->fast_outs(dmax); i < dmax; i++) {
2298         Node* use = def->fast_out(i);
2299         if (use != this &&
2300             use->Opcode() == opc &&
2301             use->req() == req()) {
2302           uint j;
2303           for (j = 0; j < use->req(); j++) {
2304             if (use->in(j) != in(j)) {
2305               break;
2306             }
2307           }
2308           if (j == use->req()) {
2309             return use;
2310           }
2311         }
2312       }
2313     }




 888   // debug_only(destruct();)   // no reuse benefit expected
 889   if (edges_to_n == 0) {
 890     C->record_dead_node(_idx);
 891   }
 892   return edges_to_n;
 893 }
 894 
 895 //-----------------------------uncast---------------------------------------
 896 // %%% Temporary, until we sort out CheckCastPP vs. CastPP.
 897 // Strip away casting.  (It is depth-limited.)
 898 Node* Node::uncast() const {
 899   // Should be inline:
 900   //return is_ConstraintCast() ? uncast_helper(this) : (Node*) this;
 901   if (is_ConstraintCast())
 902     return uncast_helper(this);
 903   else
 904     return (Node*) this;
 905 }
 906 
 907 // Find out of current node that matches opcode.
 908 Node* Node::find_out_with(uint opcode) {
 909   for (DUIterator_Fast imax, i = fast_outs(imax); i < imax; i++) {
 910     Node* use = fast_out(i);
 911     if (use->Opcode() == opcode) {
 912       return use;
 913     }
 914   }
 915   return NULL;
 916 }
 917 
 918 // Return true if the current node has an out that matches opcode.
 919 bool Node::has_out_with(uint opcode) {
 920   return (find_out_with(opcode) != NULL);
 921 }
 922 
 923 // Return true if the current node has an out that matches any of the opcodes.
 924 bool Node::has_out_with(uint opcode1, uint opcode2, uint opcode3, uint opcode4) {
 925   for (DUIterator_Fast imax, i = fast_outs(imax); i < imax; i++) {
 926       uint opcode = fast_out(i)->Opcode();
 927       if (opcode == opcode1 || opcode == opcode2 || opcode == opcode3 || opcode == opcode4) {
 928         return true;
 929       }
 930   }
 931   return false;
 932 }
 933 
 934 
 935 //---------------------------uncast_helper-------------------------------------
 936 Node* Node::uncast_helper(const Node* p) {
 937 #ifdef ASSERT
 938   uint depth_count = 0;
 939   const Node* orig_p = p;
 940 #endif
 941 
 942   while (true) {
 943 #ifdef ASSERT
 944     if (depth_count >= K) {
 945       orig_p->dump(4);
 946       if (p != orig_p)


1114 //    return new AddINode(shift, in(1));
1115 //
1116 // When making a Node for a constant use 'phase->makecon' or 'phase->intcon'.
1117 // These forms are faster than 'phase->transform(new ConNode())' and Do
1118 // The Right Thing with def-use info.
1119 //
1120 // You cannot bury the 'this' Node inside of a graph reshape.  If the reshaped
1121 // graph uses the 'this' Node it must be the root.  If you want a Node with
1122 // the same Opcode as the 'this' pointer use 'clone'.
1123 //
1124 Node *Node::Ideal(PhaseGVN *phase, bool can_reshape) {
1125   return NULL;                  // Default to being Ideal already
1126 }
1127 
1128 // Some nodes have specific Ideal subgraph transformations only if they are
1129 // unique users of specific nodes. Such nodes should be put on IGVN worklist
1130 // for the transformations to happen.
1131 bool Node::has_special_unique_user() const {
1132   assert(outcnt() == 1, "match only for unique out");
1133   Node* n = unique_out();
1134   uint op  = Opcode();
1135   if (this->is_Store()) {
1136     // Condition for back-to-back stores folding.
1137     return n->Opcode() == op && n->in(MemNode::Memory) == this;
1138   } else if (this->is_Load()) {
1139     // Condition for removing an unused LoadNode from the MemBarAcquire precedence input
1140     return n->Opcode() == Op_MemBarAcquire;
1141   } else if (op == Op_AddL) {
1142     // Condition for convL2I(addL(x,y)) ==> addI(convL2I(x),convL2I(y))
1143     return n->Opcode() == Op_ConvL2I && n->in(1) == this;
1144   } else if (op == Op_SubI || op == Op_SubL) {
1145     // Condition for subI(x,subI(y,z)) ==> subI(addI(x,z),y)
1146     return n->Opcode() == op && n->in(2) == this;
1147   } else if (is_If() && (n->is_IfFalse() || n->is_IfTrue())) {
1148     // See IfProjNode::Identity()
1149     return true;
1150   }
1151   return false;
1152 };
1153 
1154 //--------------------------find_exact_control---------------------------------


2273 // value, if it appears (by local graph inspection) to be computed by a simple conditional.
2274 bool Node::is_iteratively_computed() {
2275   if (ideal_reg()) { // does operation have a result register?
2276     for (uint i = 1; i < req(); i++) {
2277       Node* n = in(i);
2278       if (n != NULL && n->is_Phi()) {
2279         for (uint j = 1; j < n->req(); j++) {
2280           if (n->in(j) == this) {
2281             return true;
2282           }
2283         }
2284       }
2285     }
2286   }
2287   return false;
2288 }
2289 
2290 //--------------------------find_similar------------------------------
2291 // Return a node with opcode "opc" and same inputs as "this" if one can
2292 // be found; Otherwise return NULL;
2293 Node* Node::find_similar(uint opc) {
2294   if (req() >= 2) {
2295     Node* def = in(1);
2296     if (def && def->outcnt() >= 2) {
2297       for (DUIterator_Fast dmax, i = def->fast_outs(dmax); i < dmax; i++) {
2298         Node* use = def->fast_out(i);
2299         if (use != this &&
2300             use->Opcode() == opc &&
2301             use->req() == req()) {
2302           uint j;
2303           for (j = 0; j < use->req(); j++) {
2304             if (use->in(j) != in(j)) {
2305               break;
2306             }
2307           }
2308           if (j == use->req()) {
2309             return use;
2310           }
2311         }
2312       }
2313     }


< prev index next >