< prev index next >

src/hotspot/share/opto/matcher.cpp

Print this page

 166   Unique_Node_List worklist;
 167   VectorSet visited;
 168   worklist.push(xroot);
 169   while (worklist.size() > 0) {
 170     Node* n = worklist.pop();
 171     visited.set(n->_idx);
 172     assert(C->node_arena()->contains(n), "dead node");
 173     for (uint j = 0; j < n->req(); j++) {
 174       Node* in = n->in(j);
 175       if (in != NULL) {
 176         assert(C->node_arena()->contains(in), "dead node");
 177         if (!visited.test(in->_idx)) {
 178           worklist.push(in);
 179         }
 180       }
 181     }
 182   }
 183 }
 184 #endif
 185 












































 186 
 187 //---------------------------match---------------------------------------------
 188 void Matcher::match( ) {
 189   if( MaxLabelRootDepth < 100 ) { // Too small?
 190     assert(false, "invalid MaxLabelRootDepth, increase it to 100 minimum");
 191     MaxLabelRootDepth = 100;
 192   }
 193   // One-time initialization of some register masks.
 194   init_spill_mask( C->root()->in(1) );
 195   _return_addr_mask = return_addr();
 196 #ifdef _LP64
 197   // Pointers take 2 slots in 64-bit land
 198   _return_addr_mask.Insert(OptoReg::add(return_addr(),1));
 199 #endif
 200 
 201   // Map a Java-signature return type into return register-value
 202   // machine registers for 0, 1 and 2 returned values.
 203   const TypeTuple *range = C->tf()->range();
 204   if( range->cnt() > TypeFunc::Parms ) { // If not a void function
 205     // Get ideal-register return type
 206     uint ireg = range->field_at(TypeFunc::Parms)->ideal_reg();
 207     // Get machine return register
 208     uint sop = C->start()->Opcode();
 209     OptoRegPair regs = return_value(ireg);
 210 
 211     // And mask for same
 212     _return_value_mask = RegMask(regs.first());
 213     if( OptoReg::is_valid(regs.second()) )
 214       _return_value_mask.Insert(regs.second());
 215   }
 216 
 217   // ---------------
 218   // Frame Layout
 219 
 220   // Need the method signature to determine the incoming argument types,
 221   // because the types determine which registers the incoming arguments are
 222   // in, and this affects the matched code.
 223   const TypeTuple *domain = C->tf()->domain();
 224   uint             argcnt = domain->cnt() - TypeFunc::Parms;
 225   BasicType *sig_bt        = NEW_RESOURCE_ARRAY( BasicType, argcnt );
 226   VMRegPair *vm_parm_regs  = NEW_RESOURCE_ARRAY( VMRegPair, argcnt );
 227   _parm_regs               = NEW_RESOURCE_ARRAY( OptoRegPair, argcnt );
 228   _calling_convention_mask = NEW_RESOURCE_ARRAY( RegMask, argcnt );
 229   uint i;
 230   for( i = 0; i<argcnt; i++ ) {
 231     sig_bt[i] = domain->field_at(i+TypeFunc::Parms)->basic_type();
 232   }
 233 
 234   // Pass array of ideal registers and length to USER code (from the AD file)
 235   // that will convert this to an array of register numbers.
 236   const StartNode *start = C->start();
 237   start->calling_convention( sig_bt, vm_parm_regs, argcnt );
 238 #ifdef ASSERT
 239   // Sanity check users' calling convention.  Real handy while trying to
 240   // get the initial port correct.
 241   { for (uint i = 0; i<argcnt; i++) {
 242       if( !vm_parm_regs[i].first()->is_valid() && !vm_parm_regs[i].second()->is_valid() ) {
 243         assert(domain->field_at(i+TypeFunc::Parms)==Type::HALF, "only allowed on halve" );

 506   idealreg2mhdebugmask[Op_VecS] = &rms[31];
 507   idealreg2mhdebugmask[Op_VecD] = &rms[32];
 508   idealreg2mhdebugmask[Op_VecX] = &rms[33];
 509   idealreg2mhdebugmask[Op_VecY] = &rms[34];
 510   idealreg2mhdebugmask[Op_VecZ] = &rms[35];
 511 
 512   idealreg2spillmask  [Op_RegVectMask] = &rms[36];
 513   idealreg2debugmask  [Op_RegVectMask] = &rms[37];
 514   idealreg2mhdebugmask[Op_RegVectMask] = &rms[38];
 515 
 516   OptoReg::Name i;
 517 
 518   // At first, start with the empty mask
 519   C->FIRST_STACK_mask().Clear();
 520 
 521   // Add in the incoming argument area
 522   OptoReg::Name init_in = OptoReg::add(_old_SP, C->out_preserve_stack_slots());
 523   for (i = init_in; i < _in_arg_limit; i = OptoReg::add(i,1)) {
 524     C->FIRST_STACK_mask().Insert(i);
 525   }

 526   // Add in all bits past the outgoing argument area
 527   guarantee(RegMask::can_represent_arg(OptoReg::add(_out_arg_limit,-1)),
 528             "must be able to represent all call arguments in reg mask");
 529   OptoReg::Name init = _out_arg_limit;
 530   for (i = init; RegMask::can_represent(i); i = OptoReg::add(i,1)) {
 531     C->FIRST_STACK_mask().Insert(i);
 532   }
 533   // Finally, set the "infinite stack" bit.
 534   C->FIRST_STACK_mask().set_AllStack();
 535 
 536   // Make spill masks.  Registers for their class, plus FIRST_STACK_mask.
 537   RegMask aligned_stack_mask = C->FIRST_STACK_mask();
 538   // Keep spill masks aligned.
 539   aligned_stack_mask.clear_to_pairs();
 540   assert(aligned_stack_mask.is_AllStack(), "should be infinite stack");
 541   RegMask scalable_stack_mask = aligned_stack_mask;
 542 
 543   *idealreg2spillmask[Op_RegP] = *idealreg2regmask[Op_RegP];
 544 #ifdef _LP64
 545   *idealreg2spillmask[Op_RegN] = *idealreg2regmask[Op_RegN];

 764     _register_save_policy[reg] == 'E' ||
 765     _register_save_policy[reg] == 'A'; // Save-on-entry register?
 766 }
 767 
 768 //---------------------------Fixup_Save_On_Entry-------------------------------
 769 void Matcher::Fixup_Save_On_Entry( ) {
 770   init_first_stack_mask();
 771 
 772   Node *root = C->root();       // Short name for root
 773   // Count number of save-on-entry registers.
 774   uint soe_cnt = number_of_saved_registers();
 775   uint i;
 776 
 777   // Find the procedure Start Node
 778   StartNode *start = C->start();
 779   assert( start, "Expect a start node" );
 780 
 781   // Input RegMask array shared by all Returns.
 782   // The type for doubles and longs has a count of 2, but
 783   // there is only 1 returned value
 784   uint ret_edge_cnt = TypeFunc::Parms + ((C->tf()->range()->cnt() == TypeFunc::Parms) ? 0 : 1);
 785   RegMask *ret_rms  = init_input_masks( ret_edge_cnt + soe_cnt, _return_addr_mask, c_frame_ptr_mask );
 786   // Returns have 0 or 1 returned values depending on call signature.
 787   // Return register is specified by return_value in the AD file.
 788   if (ret_edge_cnt > TypeFunc::Parms)
 789     ret_rms[TypeFunc::Parms+0] = _return_value_mask;
 790 
 791   // Input RegMask array shared by all Rethrows.
 792   uint reth_edge_cnt = TypeFunc::Parms+1;
 793   RegMask *reth_rms  = init_input_masks( reth_edge_cnt + soe_cnt, _return_addr_mask, c_frame_ptr_mask );
 794   // Rethrow takes exception oop only, but in the argument 0 slot.
 795   OptoReg::Name reg = find_receiver();
 796   if (reg >= 0) {
 797     reth_rms[TypeFunc::Parms] = mreg2regmask[reg];
 798 #ifdef _LP64
 799     // Need two slots for ptrs in 64-bit land
 800     reth_rms[TypeFunc::Parms].Insert(OptoReg::add(OptoReg::Name(reg), 1));
 801 #endif
 802   }
 803 
 804   // Input RegMask array shared by all TailCalls
 805   uint tail_call_edge_cnt = TypeFunc::Parms+2;
 806   RegMask *tail_call_rms = init_input_masks( tail_call_edge_cnt + soe_cnt, _return_addr_mask, c_frame_ptr_mask );
 807 
 808   // Input RegMask array shared by all TailJumps
 809   uint tail_jump_edge_cnt = TypeFunc::Parms+2;

 836   }
 837 
 838   // Input RegMask array shared by all Halts
 839   uint halt_edge_cnt = TypeFunc::Parms;
 840   RegMask *halt_rms = init_input_masks( halt_edge_cnt + soe_cnt, _return_addr_mask, c_frame_ptr_mask );
 841 
 842   // Capture the return input masks into each exit flavor
 843   for( i=1; i < root->req(); i++ ) {
 844     MachReturnNode *exit = root->in(i)->as_MachReturn();
 845     switch( exit->ideal_Opcode() ) {
 846       case Op_Return   : exit->_in_rms = ret_rms;  break;
 847       case Op_Rethrow  : exit->_in_rms = reth_rms; break;
 848       case Op_TailCall : exit->_in_rms = tail_call_rms; break;
 849       case Op_TailJump : exit->_in_rms = tail_jump_rms; break;
 850       case Op_Halt     : exit->_in_rms = halt_rms; break;
 851       default          : ShouldNotReachHere();
 852     }
 853   }
 854 
 855   // Next unused projection number from Start.
 856   int proj_cnt = C->tf()->domain()->cnt();
 857 
 858   // Do all the save-on-entry registers.  Make projections from Start for
 859   // them, and give them a use at the exit points.  To the allocator, they
 860   // look like incoming register arguments.
 861   for( i = 0; i < _last_Mach_Reg; i++ ) {
 862     if( is_save_on_entry(i) ) {
 863 
 864       // Add the save-on-entry to the mask array
 865       ret_rms      [      ret_edge_cnt] = mreg2regmask[i];
 866       reth_rms     [     reth_edge_cnt] = mreg2regmask[i];
 867       tail_call_rms[tail_call_edge_cnt] = mreg2regmask[i];
 868       tail_jump_rms[tail_jump_edge_cnt] = mreg2regmask[i];
 869       // Halts need the SOE registers, but only in the stack as debug info.
 870       // A just-prior uncommon-trap or deoptimization will use the SOE regs.
 871       halt_rms     [     halt_edge_cnt] = *idealreg2spillmask[_register_save_type[i]];
 872 
 873       Node *mproj;
 874 
 875       // Is this a RegF low half of a RegD?  Double up 2 adjacent RegF's
 876       // into a single RegD.

1108       Node *oldn = n;
1109       // Old-space or new-space check
1110       if (!C->node_arena()->contains(n)) {
1111         // Old space!
1112         Node* m;
1113         if (has_new_node(n)) {  // Not yet Label/Reduced
1114           m = new_node(n);
1115         } else {
1116           if (!is_dontcare(n)) { // Matcher can match this guy
1117             // Calls match special.  They match alone with no children.
1118             // Their children, the incoming arguments, match normally.
1119             m = n->is_SafePoint() ? match_sfpt(n->as_SafePoint()):match_tree(n);
1120             if (C->failing())  return NULL;
1121             if (m == NULL) { Matcher::soft_match_failure(); return NULL; }
1122             if (n->is_MemBar()) {
1123               m->as_MachMemBar()->set_adr_type(n->adr_type());
1124             }
1125           } else {                  // Nothing the matcher cares about
1126             if (n->is_Proj() && n->in(0) != NULL && n->in(0)->is_Multi()) {       // Projections?
1127               // Convert to machine-dependent projection
1128               m = n->in(0)->as_Multi()->match( n->as_Proj(), this );




1129               NOT_PRODUCT(record_new2old(m, n);)
1130               if (m->in(0) != NULL) // m might be top
1131                 collect_null_checks(m, n);
1132             } else {                // Else just a regular 'ol guy
1133               m = n->clone();       // So just clone into new-space
1134               NOT_PRODUCT(record_new2old(m, n);)
1135               // Def-Use edges will be added incrementally as Uses
1136               // of this node are matched.
1137               assert(m->outcnt() == 0, "no Uses of this clone yet");
1138             }
1139           }
1140 
1141           set_new_node(n, m);       // Map old to new
1142           if (_old_node_note_array != NULL) {
1143             Node_Notes* nn = C->locate_node_notes(_old_node_note_array,
1144                                                   n->_idx);
1145             C->set_node_notes_at(m->_idx, nn);
1146           }
1147           debug_only(match_alias_type(C, n, m));
1148         }

1247   }
1248   return OptoReg::as_OptoReg(reg);
1249 }
1250 
1251 
1252 //------------------------------match_sfpt-------------------------------------
1253 // Helper function to match call instructions.  Calls match special.
1254 // They match alone with no children.  Their children, the incoming
1255 // arguments, match normally.
1256 MachNode *Matcher::match_sfpt( SafePointNode *sfpt ) {
1257   MachSafePointNode *msfpt = NULL;
1258   MachCallNode      *mcall = NULL;
1259   uint               cnt;
1260   // Split out case for SafePoint vs Call
1261   CallNode *call;
1262   const TypeTuple *domain;
1263   ciMethod*        method = NULL;
1264   bool             is_method_handle_invoke = false;  // for special kill effects
1265   if( sfpt->is_Call() ) {
1266     call = sfpt->as_Call();
1267     domain = call->tf()->domain();
1268     cnt = domain->cnt();
1269 
1270     // Match just the call, nothing else
1271     MachNode *m = match_tree(call);
1272     if (C->failing())  return NULL;
1273     if( m == NULL ) { Matcher::soft_match_failure(); return NULL; }
1274 
1275     // Copy data from the Ideal SafePoint to the machine version
1276     mcall = m->as_MachCall();
1277 
1278     mcall->set_tf(                  call->tf());
1279     mcall->set_entry_point(         call->entry_point());
1280     mcall->set_cnt(                 call->cnt());
1281     mcall->set_guaranteed_safepoint(call->guaranteed_safepoint());
1282 
1283     if( mcall->is_MachCallJava() ) {
1284       MachCallJavaNode *mcall_java  = mcall->as_MachCallJava();
1285       const CallJavaNode *call_java =  call->as_CallJava();
1286       assert(call_java->validate_symbolic_info(), "inconsistent info");
1287       method = call_java->method();

1326   msfpt->_in_rms = NEW_RESOURCE_ARRAY( RegMask, cnt );
1327   // Empty them all.
1328   for (uint i = 0; i < cnt; i++) ::new (&(msfpt->_in_rms[i])) RegMask();
1329 
1330   // Do all the pre-defined non-Empty register masks
1331   msfpt->_in_rms[TypeFunc::ReturnAdr] = _return_addr_mask;
1332   msfpt->_in_rms[TypeFunc::FramePtr ] = c_frame_ptr_mask;
1333 
1334   // Place first outgoing argument can possibly be put.
1335   OptoReg::Name begin_out_arg_area = OptoReg::add(_new_SP, C->out_preserve_stack_slots());
1336   assert( is_even(begin_out_arg_area), "" );
1337   // Compute max outgoing register number per call site.
1338   OptoReg::Name out_arg_limit_per_call = begin_out_arg_area;
1339   // Calls to C may hammer extra stack slots above and beyond any arguments.
1340   // These are usually backing store for register arguments for varargs.
1341   if( call != NULL && call->is_CallRuntime() )
1342     out_arg_limit_per_call = OptoReg::add(out_arg_limit_per_call,C->varargs_C_out_slots_killed());
1343 
1344 
1345   // Do the normal argument list (parameters) register masks
1346   int argcnt = cnt - TypeFunc::Parms;



1347   if( argcnt > 0 ) {          // Skip it all if we have no args
1348     BasicType *sig_bt  = NEW_RESOURCE_ARRAY( BasicType, argcnt );
1349     VMRegPair *parm_regs = NEW_RESOURCE_ARRAY( VMRegPair, argcnt );
1350     int i;
1351     for( i = 0; i < argcnt; i++ ) {
1352       sig_bt[i] = domain->field_at(i+TypeFunc::Parms)->basic_type();
1353     }
1354     // V-call to pick proper calling convention
1355     call->calling_convention( sig_bt, parm_regs, argcnt );
1356 
1357 #ifdef ASSERT
1358     // Sanity check users' calling convention.  Really handy during
1359     // the initial porting effort.  Fairly expensive otherwise.
1360     { for (int i = 0; i<argcnt; i++) {
1361       if( !parm_regs[i].first()->is_valid() &&
1362           !parm_regs[i].second()->is_valid() ) continue;
1363       VMReg reg1 = parm_regs[i].first();
1364       VMReg reg2 = parm_regs[i].second();
1365       for (int j = 0; j < i; j++) {
1366         if( !parm_regs[j].first()->is_valid() &&
1367             !parm_regs[j].second()->is_valid() ) continue;
1368         VMReg reg3 = parm_regs[j].first();
1369         VMReg reg4 = parm_regs[j].second();
1370         if( !reg1->is_valid() ) {
1371           assert( !reg2->is_valid(), "valid halvsies" );
1372         } else if( !reg3->is_valid() ) {
1373           assert( !reg4->is_valid(), "valid halvsies" );
1374         } else {
1375           assert( reg1 != reg2, "calling conv. must produce distinct regs");
1376           assert( reg1 != reg3, "calling conv. must produce distinct regs");
1377           assert( reg1 != reg4, "calling conv. must produce distinct regs");
1378           assert( reg2 != reg3, "calling conv. must produce distinct regs");
1379           assert( reg2 != reg4 || !reg2->is_valid(), "calling conv. must produce distinct regs");
1380           assert( reg3 != reg4, "calling conv. must produce distinct regs");
1381         }
1382       }
1383     }
1384     }
1385 #endif
1386 
1387     // Visit each argument.  Compute its outgoing register mask.
1388     // Return results now can have 2 bits returned.
1389     // Compute max over all outgoing arguments both per call-site
1390     // and over the entire method.
1391     for( i = 0; i < argcnt; i++ ) {
1392       // Address of incoming argument mask to fill in
1393       RegMask *rm = &mcall->_in_rms[i+TypeFunc::Parms];
1394       VMReg first = parm_regs[i].first();
1395       VMReg second = parm_regs[i].second();
1396       if(!first->is_valid() &&
1397          !second->is_valid()) {
1398         continue;               // Avoid Halves
1399       }
1400       // Handle case where arguments are in vector registers.
1401       if(call->in(TypeFunc::Parms + i)->bottom_type()->isa_vect()) {
1402         OptoReg::Name reg_fst = OptoReg::as_OptoReg(first);
1403         OptoReg::Name reg_snd = OptoReg::as_OptoReg(second);
1404         assert (reg_fst <= reg_snd, "fst=%d snd=%d", reg_fst, reg_snd);
1405         for (OptoReg::Name r = reg_fst; r <= reg_snd; r++) {
1406           rm->Insert(r);
1407         }
1408       }
1409       // Grab first register, adjust stack slots and insert in mask.
1410       OptoReg::Name reg1 = warp_outgoing_stk_arg(first, begin_out_arg_area, out_arg_limit_per_call );
1411       if (OptoReg::is_valid(reg1))
1412         rm->Insert( reg1 );

1413       // Grab second register (if any), adjust stack slots and insert in mask.
1414       OptoReg::Name reg2 = warp_outgoing_stk_arg(second, begin_out_arg_area, out_arg_limit_per_call );
1415       if (OptoReg::is_valid(reg2))
1416         rm->Insert( reg2 );

1417     } // End of for all arguments
1418   }
1419 
1420   // Compute the max stack slot killed by any call.  These will not be
1421   // available for debug info, and will be used to adjust FIRST_STACK_mask
1422   // after all call sites have been visited.
1423   if( _out_arg_limit < out_arg_limit_per_call)
1424     _out_arg_limit = out_arg_limit_per_call;
1425 
1426   if (mcall) {
1427     // Kill the outgoing argument area, including any non-argument holes and
1428     // any legacy C-killed slots.  Use Fat-Projections to do the killing.
1429     // Since the max-per-method covers the max-per-call-site and debug info
1430     // is excluded on the max-per-method basis, debug info cannot land in
1431     // this killed area.
1432     uint r_cnt = mcall->tf()->range()->cnt();
1433     MachProjNode *proj = new MachProjNode( mcall, r_cnt+10000, RegMask::Empty, MachProjNode::fat_proj );
1434     if (!RegMask::can_represent_arg(OptoReg::Name(out_arg_limit_per_call-1))) {
1435       C->record_method_not_compilable("unsupported outgoing calling sequence");
1436     } else {
1437       for (int i = begin_out_arg_area; i < out_arg_limit_per_call; i++)
1438         proj->_rout.Insert(OptoReg::Name(i));
1439     }
1440     if (proj->_rout.is_NotEmpty()) {
1441       push_projection(proj);
1442     }
1443   }
1444   // Transfer the safepoint information from the call to the mcall
1445   // Move the JVMState list
1446   msfpt->set_jvms(sfpt->jvms());
1447   for (JVMState* jvms = msfpt->jvms(); jvms; jvms = jvms->caller()) {
1448     jvms->set_map(sfpt);
1449   }
1450 
1451   // Debug inputs begin just after the last incoming parameter
1452   assert((mcall == NULL) || (mcall->jvms() == NULL) ||
1453          (mcall->jvms()->debug_start() + mcall->_jvmadj == mcall->tf()->domain()->cnt()), "");
1454 
1455   // Add additional edges.
1456   if (msfpt->mach_constant_base_node_input() != (uint)-1 && !msfpt->is_MachCallLeaf()) {
1457     // For these calls we can not add MachConstantBase in expand(), as the
1458     // ins are not complete then.
1459     msfpt->ins_req(msfpt->mach_constant_base_node_input(), C->mach_constant_base_node());
1460     if (msfpt->jvms() &&
1461         msfpt->mach_constant_base_node_input() <= msfpt->jvms()->debug_start() + msfpt->_jvmadj) {
1462       // We added an edge before jvms, so we must adapt the position of the ins.
1463       msfpt->jvms()->adapt_position(+1);
1464     }
1465   }
1466 
1467   // Registers killed by the call are set in the local scheduling pass
1468   // of Global Code Motion.
1469   return msfpt;
1470 }
1471 
1472 //---------------------------match_tree----------------------------------------
1473 // Match a Ideal Node DAG - turn it into a tree; Label & Reduce.  Used as part

2116         set_shared(n);       // Flag as shared and
2117         if (n->is_DecodeNarrowPtr()) {
2118           // Oop field/array element loads must be shared but since
2119           // they are shared through a DecodeN they may appear to have
2120           // a single use so force sharing here.
2121           set_shared(n->in(1));
2122         }
2123         mstack.pop();        // remove node from stack
2124         continue;
2125       }
2126       nstate = Visit; // Not already visited; so visit now
2127     }
2128     if (nstate == Visit) {
2129       mstack.set_state(Post_Visit);
2130       set_visited(n);   // Flag as visited now
2131       bool mem_op = false;
2132       int mem_addr_idx = MemNode::Address;
2133       if (find_shared_visit(mstack, n, nop, mem_op, mem_addr_idx)) {
2134         continue;
2135       }
2136       for (int i = n->req() - 1; i >= 0; --i) { // For my children
2137         Node* m = n->in(i); // Get ith input
2138         if (m == NULL) {
2139           continue;  // Ignore NULLs
2140         }
2141         if (clone_node(n, m, mstack)) {
2142           continue;
2143         }
2144 
2145         // Clone addressing expressions as they are "free" in memory access instructions
2146         if (mem_op && i == mem_addr_idx && m->is_AddP() &&
2147             // When there are other uses besides address expressions
2148             // put it on stack and mark as shared.
2149             !is_visited(m)) {
2150           // Some inputs for address expression are not put on stack
2151           // to avoid marking them as shared and forcing them into register
2152           // if they are used only in address expressions.
2153           // But they should be marked as shared if there are other uses
2154           // besides address expressions.
2155 
2156           if (pd_clone_address_expressions(m->as_AddP(), mstack, address_visited)) {

2428     case Op_FmaD:
2429     case Op_FmaF:
2430     case Op_FmaVD:
2431     case Op_FmaVF: {
2432       // Restructure into a binary tree for Matching.
2433       Node* pair = new BinaryNode(n->in(1), n->in(2));
2434       n->set_req(2, pair);
2435       n->set_req(1, n->in(3));
2436       n->del_req(3);
2437       break;
2438     }
2439     case Op_MulAddS2I: {
2440       Node* pair1 = new BinaryNode(n->in(1), n->in(2));
2441       Node* pair2 = new BinaryNode(n->in(3), n->in(4));
2442       n->set_req(1, pair1);
2443       n->set_req(2, pair2);
2444       n->del_req(4);
2445       n->del_req(3);
2446       break;
2447     }







2448     case Op_CopySignD:
2449     case Op_SignumVF:
2450     case Op_SignumVD:
2451     case Op_SignumF:
2452     case Op_SignumD: {
2453       Node* pair = new BinaryNode(n->in(2), n->in(3));
2454       n->set_req(2, pair);
2455       n->del_req(3);
2456       break;
2457     }
2458     case Op_VectorBlend:
2459     case Op_VectorInsert: {
2460       Node* pair = new BinaryNode(n->in(1), n->in(2));
2461       n->set_req(1, pair);
2462       n->set_req(2, n->in(3));
2463       n->del_req(3);
2464       break;
2465     }
2466     case Op_LoadVectorGatherMasked:
2467     case Op_StoreVectorScatter: {

 166   Unique_Node_List worklist;
 167   VectorSet visited;
 168   worklist.push(xroot);
 169   while (worklist.size() > 0) {
 170     Node* n = worklist.pop();
 171     visited.set(n->_idx);
 172     assert(C->node_arena()->contains(n), "dead node");
 173     for (uint j = 0; j < n->req(); j++) {
 174       Node* in = n->in(j);
 175       if (in != NULL) {
 176         assert(C->node_arena()->contains(in), "dead node");
 177         if (!visited.test(in->_idx)) {
 178           worklist.push(in);
 179         }
 180       }
 181     }
 182   }
 183 }
 184 #endif
 185 
 186 // Array of RegMask, one per returned values (inline type instances can
 187 // be returned as multiple return values, one per field)
 188 RegMask* Matcher::return_values_mask(const TypeFunc* tf) {
 189   const TypeTuple* range = tf->range_cc();
 190   uint cnt = range->cnt() - TypeFunc::Parms;
 191   if (cnt == 0) {
 192     return NULL;
 193   }
 194   RegMask* mask = NEW_RESOURCE_ARRAY(RegMask, cnt);
 195   BasicType* sig_bt = NEW_RESOURCE_ARRAY(BasicType, cnt);
 196   VMRegPair* vm_parm_regs = NEW_RESOURCE_ARRAY(VMRegPair, cnt);
 197   for (uint i = 0; i < cnt; i++) {
 198     sig_bt[i] = range->field_at(i+TypeFunc::Parms)->basic_type();
 199   }
 200 
 201   int regs = SharedRuntime::java_return_convention(sig_bt, vm_parm_regs, cnt);
 202   if (regs <= 0) {
 203     // We ran out of registers to store the IsInit information for a nullable inline type return.
 204     // Since it is only set in the 'call_epilog', we can simply put it on the stack.
 205     assert(tf->returns_inline_type_as_fields(), "should have been tested during graph construction");
 206     // TODO 8284443 Can we teach the register allocator to reserve a stack slot instead?
 207     // mask[--cnt] = STACK_ONLY_mask does not work (test with -XX:+StressGCM)
 208     int slot = C->fixed_slots() - 2;
 209     if (C->needs_stack_repair()) {
 210       slot -= 2; // Account for stack increment value
 211     }
 212     mask[--cnt].Clear();
 213     mask[cnt].Insert(OptoReg::stack2reg(slot));
 214   }
 215   for (uint i = 0; i < cnt; i++) {
 216     mask[i].Clear();
 217 
 218     OptoReg::Name reg1 = OptoReg::as_OptoReg(vm_parm_regs[i].first());
 219     if (OptoReg::is_valid(reg1)) {
 220       mask[i].Insert(reg1);
 221     }
 222     OptoReg::Name reg2 = OptoReg::as_OptoReg(vm_parm_regs[i].second());
 223     if (OptoReg::is_valid(reg2)) {
 224       mask[i].Insert(reg2);
 225     }
 226   }
 227 
 228   return mask;
 229 }
 230 
 231 //---------------------------match---------------------------------------------
 232 void Matcher::match( ) {
 233   if( MaxLabelRootDepth < 100 ) { // Too small?
 234     assert(false, "invalid MaxLabelRootDepth, increase it to 100 minimum");
 235     MaxLabelRootDepth = 100;
 236   }
 237   // One-time initialization of some register masks.
 238   init_spill_mask( C->root()->in(1) );
 239   _return_addr_mask = return_addr();
 240 #ifdef _LP64
 241   // Pointers take 2 slots in 64-bit land
 242   _return_addr_mask.Insert(OptoReg::add(return_addr(),1));
 243 #endif
 244 
 245   // Map Java-signature return types into return register-value
 246   // machine registers.
 247   _return_values_mask = return_values_mask(C->tf());












 248 
 249   // ---------------
 250   // Frame Layout
 251 
 252   // Need the method signature to determine the incoming argument types,
 253   // because the types determine which registers the incoming arguments are
 254   // in, and this affects the matched code.
 255   const TypeTuple *domain = C->tf()->domain_cc();
 256   uint             argcnt = domain->cnt() - TypeFunc::Parms;
 257   BasicType *sig_bt        = NEW_RESOURCE_ARRAY( BasicType, argcnt );
 258   VMRegPair *vm_parm_regs  = NEW_RESOURCE_ARRAY( VMRegPair, argcnt );
 259   _parm_regs               = NEW_RESOURCE_ARRAY( OptoRegPair, argcnt );
 260   _calling_convention_mask = NEW_RESOURCE_ARRAY( RegMask, argcnt );
 261   uint i;
 262   for( i = 0; i<argcnt; i++ ) {
 263     sig_bt[i] = domain->field_at(i+TypeFunc::Parms)->basic_type();
 264   }
 265 
 266   // Pass array of ideal registers and length to USER code (from the AD file)
 267   // that will convert this to an array of register numbers.
 268   const StartNode *start = C->start();
 269   start->calling_convention( sig_bt, vm_parm_regs, argcnt );
 270 #ifdef ASSERT
 271   // Sanity check users' calling convention.  Real handy while trying to
 272   // get the initial port correct.
 273   { for (uint i = 0; i<argcnt; i++) {
 274       if( !vm_parm_regs[i].first()->is_valid() && !vm_parm_regs[i].second()->is_valid() ) {
 275         assert(domain->field_at(i+TypeFunc::Parms)==Type::HALF, "only allowed on halve" );

 538   idealreg2mhdebugmask[Op_VecS] = &rms[31];
 539   idealreg2mhdebugmask[Op_VecD] = &rms[32];
 540   idealreg2mhdebugmask[Op_VecX] = &rms[33];
 541   idealreg2mhdebugmask[Op_VecY] = &rms[34];
 542   idealreg2mhdebugmask[Op_VecZ] = &rms[35];
 543 
 544   idealreg2spillmask  [Op_RegVectMask] = &rms[36];
 545   idealreg2debugmask  [Op_RegVectMask] = &rms[37];
 546   idealreg2mhdebugmask[Op_RegVectMask] = &rms[38];
 547 
 548   OptoReg::Name i;
 549 
 550   // At first, start with the empty mask
 551   C->FIRST_STACK_mask().Clear();
 552 
 553   // Add in the incoming argument area
 554   OptoReg::Name init_in = OptoReg::add(_old_SP, C->out_preserve_stack_slots());
 555   for (i = init_in; i < _in_arg_limit; i = OptoReg::add(i,1)) {
 556     C->FIRST_STACK_mask().Insert(i);
 557   }
 558 
 559   // Add in all bits past the outgoing argument area
 560   guarantee(RegMask::can_represent_arg(OptoReg::add(_out_arg_limit,-1)),
 561             "must be able to represent all call arguments in reg mask");
 562   OptoReg::Name init = _out_arg_limit;
 563   for (i = init; RegMask::can_represent(i); i = OptoReg::add(i,1)) {
 564     C->FIRST_STACK_mask().Insert(i);
 565   }
 566   // Finally, set the "infinite stack" bit.
 567   C->FIRST_STACK_mask().set_AllStack();
 568 
 569   // Make spill masks.  Registers for their class, plus FIRST_STACK_mask.
 570   RegMask aligned_stack_mask = C->FIRST_STACK_mask();
 571   // Keep spill masks aligned.
 572   aligned_stack_mask.clear_to_pairs();
 573   assert(aligned_stack_mask.is_AllStack(), "should be infinite stack");
 574   RegMask scalable_stack_mask = aligned_stack_mask;
 575 
 576   *idealreg2spillmask[Op_RegP] = *idealreg2regmask[Op_RegP];
 577 #ifdef _LP64
 578   *idealreg2spillmask[Op_RegN] = *idealreg2regmask[Op_RegN];

 797     _register_save_policy[reg] == 'E' ||
 798     _register_save_policy[reg] == 'A'; // Save-on-entry register?
 799 }
 800 
 801 //---------------------------Fixup_Save_On_Entry-------------------------------
 802 void Matcher::Fixup_Save_On_Entry( ) {
 803   init_first_stack_mask();
 804 
 805   Node *root = C->root();       // Short name for root
 806   // Count number of save-on-entry registers.
 807   uint soe_cnt = number_of_saved_registers();
 808   uint i;
 809 
 810   // Find the procedure Start Node
 811   StartNode *start = C->start();
 812   assert( start, "Expect a start node" );
 813 
 814   // Input RegMask array shared by all Returns.
 815   // The type for doubles and longs has a count of 2, but
 816   // there is only 1 returned value
 817   uint ret_edge_cnt = C->tf()->range_cc()->cnt();
 818   RegMask *ret_rms  = init_input_masks( ret_edge_cnt + soe_cnt, _return_addr_mask, c_frame_ptr_mask );
 819   for (i = TypeFunc::Parms; i < ret_edge_cnt; i++) {
 820     ret_rms[i] = _return_values_mask[i-TypeFunc::Parms];
 821   }

 822 
 823   // Input RegMask array shared by all Rethrows.
 824   uint reth_edge_cnt = TypeFunc::Parms+1;
 825   RegMask *reth_rms  = init_input_masks( reth_edge_cnt + soe_cnt, _return_addr_mask, c_frame_ptr_mask );
 826   // Rethrow takes exception oop only, but in the argument 0 slot.
 827   OptoReg::Name reg = find_receiver();
 828   if (reg >= 0) {
 829     reth_rms[TypeFunc::Parms] = mreg2regmask[reg];
 830 #ifdef _LP64
 831     // Need two slots for ptrs in 64-bit land
 832     reth_rms[TypeFunc::Parms].Insert(OptoReg::add(OptoReg::Name(reg), 1));
 833 #endif
 834   }
 835 
 836   // Input RegMask array shared by all TailCalls
 837   uint tail_call_edge_cnt = TypeFunc::Parms+2;
 838   RegMask *tail_call_rms = init_input_masks( tail_call_edge_cnt + soe_cnt, _return_addr_mask, c_frame_ptr_mask );
 839 
 840   // Input RegMask array shared by all TailJumps
 841   uint tail_jump_edge_cnt = TypeFunc::Parms+2;

 868   }
 869 
 870   // Input RegMask array shared by all Halts
 871   uint halt_edge_cnt = TypeFunc::Parms;
 872   RegMask *halt_rms = init_input_masks( halt_edge_cnt + soe_cnt, _return_addr_mask, c_frame_ptr_mask );
 873 
 874   // Capture the return input masks into each exit flavor
 875   for( i=1; i < root->req(); i++ ) {
 876     MachReturnNode *exit = root->in(i)->as_MachReturn();
 877     switch( exit->ideal_Opcode() ) {
 878       case Op_Return   : exit->_in_rms = ret_rms;  break;
 879       case Op_Rethrow  : exit->_in_rms = reth_rms; break;
 880       case Op_TailCall : exit->_in_rms = tail_call_rms; break;
 881       case Op_TailJump : exit->_in_rms = tail_jump_rms; break;
 882       case Op_Halt     : exit->_in_rms = halt_rms; break;
 883       default          : ShouldNotReachHere();
 884     }
 885   }
 886 
 887   // Next unused projection number from Start.
 888   int proj_cnt = C->tf()->domain_cc()->cnt();
 889 
 890   // Do all the save-on-entry registers.  Make projections from Start for
 891   // them, and give them a use at the exit points.  To the allocator, they
 892   // look like incoming register arguments.
 893   for( i = 0; i < _last_Mach_Reg; i++ ) {
 894     if( is_save_on_entry(i) ) {
 895 
 896       // Add the save-on-entry to the mask array
 897       ret_rms      [      ret_edge_cnt] = mreg2regmask[i];
 898       reth_rms     [     reth_edge_cnt] = mreg2regmask[i];
 899       tail_call_rms[tail_call_edge_cnt] = mreg2regmask[i];
 900       tail_jump_rms[tail_jump_edge_cnt] = mreg2regmask[i];
 901       // Halts need the SOE registers, but only in the stack as debug info.
 902       // A just-prior uncommon-trap or deoptimization will use the SOE regs.
 903       halt_rms     [     halt_edge_cnt] = *idealreg2spillmask[_register_save_type[i]];
 904 
 905       Node *mproj;
 906 
 907       // Is this a RegF low half of a RegD?  Double up 2 adjacent RegF's
 908       // into a single RegD.

1140       Node *oldn = n;
1141       // Old-space or new-space check
1142       if (!C->node_arena()->contains(n)) {
1143         // Old space!
1144         Node* m;
1145         if (has_new_node(n)) {  // Not yet Label/Reduced
1146           m = new_node(n);
1147         } else {
1148           if (!is_dontcare(n)) { // Matcher can match this guy
1149             // Calls match special.  They match alone with no children.
1150             // Their children, the incoming arguments, match normally.
1151             m = n->is_SafePoint() ? match_sfpt(n->as_SafePoint()):match_tree(n);
1152             if (C->failing())  return NULL;
1153             if (m == NULL) { Matcher::soft_match_failure(); return NULL; }
1154             if (n->is_MemBar()) {
1155               m->as_MachMemBar()->set_adr_type(n->adr_type());
1156             }
1157           } else {                  // Nothing the matcher cares about
1158             if (n->is_Proj() && n->in(0) != NULL && n->in(0)->is_Multi()) {       // Projections?
1159               // Convert to machine-dependent projection
1160               RegMask* mask = NULL;
1161               if (n->in(0)->is_Call() && n->in(0)->as_Call()->tf()->returns_inline_type_as_fields()) {
1162                 mask = return_values_mask(n->in(0)->as_Call()->tf());
1163               }
1164               m = n->in(0)->as_Multi()->match(n->as_Proj(), this, mask);
1165               NOT_PRODUCT(record_new2old(m, n);)
1166               if (m->in(0) != NULL) // m might be top
1167                 collect_null_checks(m, n);
1168             } else {                // Else just a regular 'ol guy
1169               m = n->clone();       // So just clone into new-space
1170               NOT_PRODUCT(record_new2old(m, n);)
1171               // Def-Use edges will be added incrementally as Uses
1172               // of this node are matched.
1173               assert(m->outcnt() == 0, "no Uses of this clone yet");
1174             }
1175           }
1176 
1177           set_new_node(n, m);       // Map old to new
1178           if (_old_node_note_array != NULL) {
1179             Node_Notes* nn = C->locate_node_notes(_old_node_note_array,
1180                                                   n->_idx);
1181             C->set_node_notes_at(m->_idx, nn);
1182           }
1183           debug_only(match_alias_type(C, n, m));
1184         }

1283   }
1284   return OptoReg::as_OptoReg(reg);
1285 }
1286 
1287 
1288 //------------------------------match_sfpt-------------------------------------
1289 // Helper function to match call instructions.  Calls match special.
1290 // They match alone with no children.  Their children, the incoming
1291 // arguments, match normally.
1292 MachNode *Matcher::match_sfpt( SafePointNode *sfpt ) {
1293   MachSafePointNode *msfpt = NULL;
1294   MachCallNode      *mcall = NULL;
1295   uint               cnt;
1296   // Split out case for SafePoint vs Call
1297   CallNode *call;
1298   const TypeTuple *domain;
1299   ciMethod*        method = NULL;
1300   bool             is_method_handle_invoke = false;  // for special kill effects
1301   if( sfpt->is_Call() ) {
1302     call = sfpt->as_Call();
1303     domain = call->tf()->domain_cc();
1304     cnt = domain->cnt();
1305 
1306     // Match just the call, nothing else
1307     MachNode *m = match_tree(call);
1308     if (C->failing())  return NULL;
1309     if( m == NULL ) { Matcher::soft_match_failure(); return NULL; }
1310 
1311     // Copy data from the Ideal SafePoint to the machine version
1312     mcall = m->as_MachCall();
1313 
1314     mcall->set_tf(                  call->tf());
1315     mcall->set_entry_point(         call->entry_point());
1316     mcall->set_cnt(                 call->cnt());
1317     mcall->set_guaranteed_safepoint(call->guaranteed_safepoint());
1318 
1319     if( mcall->is_MachCallJava() ) {
1320       MachCallJavaNode *mcall_java  = mcall->as_MachCallJava();
1321       const CallJavaNode *call_java =  call->as_CallJava();
1322       assert(call_java->validate_symbolic_info(), "inconsistent info");
1323       method = call_java->method();

1362   msfpt->_in_rms = NEW_RESOURCE_ARRAY( RegMask, cnt );
1363   // Empty them all.
1364   for (uint i = 0; i < cnt; i++) ::new (&(msfpt->_in_rms[i])) RegMask();
1365 
1366   // Do all the pre-defined non-Empty register masks
1367   msfpt->_in_rms[TypeFunc::ReturnAdr] = _return_addr_mask;
1368   msfpt->_in_rms[TypeFunc::FramePtr ] = c_frame_ptr_mask;
1369 
1370   // Place first outgoing argument can possibly be put.
1371   OptoReg::Name begin_out_arg_area = OptoReg::add(_new_SP, C->out_preserve_stack_slots());
1372   assert( is_even(begin_out_arg_area), "" );
1373   // Compute max outgoing register number per call site.
1374   OptoReg::Name out_arg_limit_per_call = begin_out_arg_area;
1375   // Calls to C may hammer extra stack slots above and beyond any arguments.
1376   // These are usually backing store for register arguments for varargs.
1377   if( call != NULL && call->is_CallRuntime() )
1378     out_arg_limit_per_call = OptoReg::add(out_arg_limit_per_call,C->varargs_C_out_slots_killed());
1379 
1380 
1381   // Do the normal argument list (parameters) register masks
1382   // Null entry point is a special cast where the target of the call
1383   // is in a register.
1384   int adj = (call != NULL && call->entry_point() == NULL) ? 1 : 0;
1385   int argcnt = cnt - TypeFunc::Parms - adj;
1386   if( argcnt > 0 ) {          // Skip it all if we have no args
1387     BasicType *sig_bt  = NEW_RESOURCE_ARRAY( BasicType, argcnt );
1388     VMRegPair *parm_regs = NEW_RESOURCE_ARRAY( VMRegPair, argcnt );
1389     int i;
1390     for( i = 0; i < argcnt; i++ ) {
1391       sig_bt[i] = domain->field_at(i+TypeFunc::Parms+adj)->basic_type();
1392     }
1393     // V-call to pick proper calling convention
1394     call->calling_convention( sig_bt, parm_regs, argcnt );
1395 
1396 #ifdef ASSERT
1397     // Sanity check users' calling convention.  Really handy during
1398     // the initial porting effort.  Fairly expensive otherwise.
1399     { for (int i = 0; i<argcnt; i++) {
1400       if( !parm_regs[i].first()->is_valid() &&
1401           !parm_regs[i].second()->is_valid() ) continue;
1402       VMReg reg1 = parm_regs[i].first();
1403       VMReg reg2 = parm_regs[i].second();
1404       for (int j = 0; j < i; j++) {
1405         if( !parm_regs[j].first()->is_valid() &&
1406             !parm_regs[j].second()->is_valid() ) continue;
1407         VMReg reg3 = parm_regs[j].first();
1408         VMReg reg4 = parm_regs[j].second();
1409         if( !reg1->is_valid() ) {
1410           assert( !reg2->is_valid(), "valid halvsies" );
1411         } else if( !reg3->is_valid() ) {
1412           assert( !reg4->is_valid(), "valid halvsies" );
1413         } else {
1414           assert( reg1 != reg2, "calling conv. must produce distinct regs");
1415           assert( reg1 != reg3, "calling conv. must produce distinct regs");
1416           assert( reg1 != reg4, "calling conv. must produce distinct regs");
1417           assert( reg2 != reg3, "calling conv. must produce distinct regs");
1418           assert( reg2 != reg4 || !reg2->is_valid(), "calling conv. must produce distinct regs");
1419           assert( reg3 != reg4, "calling conv. must produce distinct regs");
1420         }
1421       }
1422     }
1423     }
1424 #endif
1425 
1426     // Visit each argument.  Compute its outgoing register mask.
1427     // Return results now can have 2 bits returned.
1428     // Compute max over all outgoing arguments both per call-site
1429     // and over the entire method.
1430     for( i = 0; i < argcnt; i++ ) {
1431       // Address of incoming argument mask to fill in
1432       RegMask *rm = &mcall->_in_rms[i+TypeFunc::Parms+adj];
1433       VMReg first = parm_regs[i].first();
1434       VMReg second = parm_regs[i].second();
1435       if(!first->is_valid() &&
1436          !second->is_valid()) {
1437         continue;               // Avoid Halves
1438       }
1439       // Handle case where arguments are in vector registers.
1440       if(call->in(TypeFunc::Parms + i)->bottom_type()->isa_vect()) {
1441         OptoReg::Name reg_fst = OptoReg::as_OptoReg(first);
1442         OptoReg::Name reg_snd = OptoReg::as_OptoReg(second);
1443         assert (reg_fst <= reg_snd, "fst=%d snd=%d", reg_fst, reg_snd);
1444         for (OptoReg::Name r = reg_fst; r <= reg_snd; r++) {
1445           rm->Insert(r);
1446         }
1447       }
1448       // Grab first register, adjust stack slots and insert in mask.
1449       OptoReg::Name reg1 = warp_outgoing_stk_arg(first, begin_out_arg_area, out_arg_limit_per_call );
1450       if (OptoReg::is_valid(reg1)) {
1451         rm->Insert( reg1 );
1452       }
1453       // Grab second register (if any), adjust stack slots and insert in mask.
1454       OptoReg::Name reg2 = warp_outgoing_stk_arg(second, begin_out_arg_area, out_arg_limit_per_call );
1455       if (OptoReg::is_valid(reg2)) {
1456         rm->Insert( reg2 );
1457       }
1458     } // End of for all arguments
1459   }
1460 
1461   // Compute the max stack slot killed by any call.  These will not be
1462   // available for debug info, and will be used to adjust FIRST_STACK_mask
1463   // after all call sites have been visited.
1464   if( _out_arg_limit < out_arg_limit_per_call)
1465     _out_arg_limit = out_arg_limit_per_call;
1466 
1467   if (mcall) {
1468     // Kill the outgoing argument area, including any non-argument holes and
1469     // any legacy C-killed slots.  Use Fat-Projections to do the killing.
1470     // Since the max-per-method covers the max-per-call-site and debug info
1471     // is excluded on the max-per-method basis, debug info cannot land in
1472     // this killed area.
1473     uint r_cnt = mcall->tf()->range_sig()->cnt();
1474     MachProjNode *proj = new MachProjNode( mcall, r_cnt+10000, RegMask::Empty, MachProjNode::fat_proj );
1475     if (!RegMask::can_represent_arg(OptoReg::Name(out_arg_limit_per_call-1))) {
1476       C->record_method_not_compilable("unsupported outgoing calling sequence");
1477     } else {
1478       for (int i = begin_out_arg_area; i < out_arg_limit_per_call; i++)
1479         proj->_rout.Insert(OptoReg::Name(i));
1480     }
1481     if (proj->_rout.is_NotEmpty()) {
1482       push_projection(proj);
1483     }
1484   }
1485   // Transfer the safepoint information from the call to the mcall
1486   // Move the JVMState list
1487   msfpt->set_jvms(sfpt->jvms());
1488   for (JVMState* jvms = msfpt->jvms(); jvms; jvms = jvms->caller()) {
1489     jvms->set_map(sfpt);
1490   }
1491 
1492   // Debug inputs begin just after the last incoming parameter
1493   assert((mcall == NULL) || (mcall->jvms() == NULL) ||
1494          (mcall->jvms()->debug_start() + mcall->_jvmadj == mcall->tf()->domain_cc()->cnt()), "");
1495 
1496   // Add additional edges.
1497   if (msfpt->mach_constant_base_node_input() != (uint)-1 && !msfpt->is_MachCallLeaf()) {
1498     // For these calls we can not add MachConstantBase in expand(), as the
1499     // ins are not complete then.
1500     msfpt->ins_req(msfpt->mach_constant_base_node_input(), C->mach_constant_base_node());
1501     if (msfpt->jvms() &&
1502         msfpt->mach_constant_base_node_input() <= msfpt->jvms()->debug_start() + msfpt->_jvmadj) {
1503       // We added an edge before jvms, so we must adapt the position of the ins.
1504       msfpt->jvms()->adapt_position(+1);
1505     }
1506   }
1507 
1508   // Registers killed by the call are set in the local scheduling pass
1509   // of Global Code Motion.
1510   return msfpt;
1511 }
1512 
1513 //---------------------------match_tree----------------------------------------
1514 // Match a Ideal Node DAG - turn it into a tree; Label & Reduce.  Used as part

2157         set_shared(n);       // Flag as shared and
2158         if (n->is_DecodeNarrowPtr()) {
2159           // Oop field/array element loads must be shared but since
2160           // they are shared through a DecodeN they may appear to have
2161           // a single use so force sharing here.
2162           set_shared(n->in(1));
2163         }
2164         mstack.pop();        // remove node from stack
2165         continue;
2166       }
2167       nstate = Visit; // Not already visited; so visit now
2168     }
2169     if (nstate == Visit) {
2170       mstack.set_state(Post_Visit);
2171       set_visited(n);   // Flag as visited now
2172       bool mem_op = false;
2173       int mem_addr_idx = MemNode::Address;
2174       if (find_shared_visit(mstack, n, nop, mem_op, mem_addr_idx)) {
2175         continue;
2176       }
2177       for (int i = n->len() - 1; i >= 0; --i) { // For my children
2178         Node* m = n->in(i); // Get ith input
2179         if (m == NULL) {
2180           continue;  // Ignore NULLs
2181         }
2182         if (clone_node(n, m, mstack)) {
2183           continue;
2184         }
2185 
2186         // Clone addressing expressions as they are "free" in memory access instructions
2187         if (mem_op && i == mem_addr_idx && m->is_AddP() &&
2188             // When there are other uses besides address expressions
2189             // put it on stack and mark as shared.
2190             !is_visited(m)) {
2191           // Some inputs for address expression are not put on stack
2192           // to avoid marking them as shared and forcing them into register
2193           // if they are used only in address expressions.
2194           // But they should be marked as shared if there are other uses
2195           // besides address expressions.
2196 
2197           if (pd_clone_address_expressions(m->as_AddP(), mstack, address_visited)) {

2469     case Op_FmaD:
2470     case Op_FmaF:
2471     case Op_FmaVD:
2472     case Op_FmaVF: {
2473       // Restructure into a binary tree for Matching.
2474       Node* pair = new BinaryNode(n->in(1), n->in(2));
2475       n->set_req(2, pair);
2476       n->set_req(1, n->in(3));
2477       n->del_req(3);
2478       break;
2479     }
2480     case Op_MulAddS2I: {
2481       Node* pair1 = new BinaryNode(n->in(1), n->in(2));
2482       Node* pair2 = new BinaryNode(n->in(3), n->in(4));
2483       n->set_req(1, pair1);
2484       n->set_req(2, pair2);
2485       n->del_req(4);
2486       n->del_req(3);
2487       break;
2488     }
2489     case Op_ClearArray: {
2490       Node* pair = new BinaryNode(n->in(2), n->in(3));
2491       n->set_req(2, pair);
2492       n->set_req(3, n->in(4));
2493       n->del_req(4);
2494       break;
2495     }
2496     case Op_CopySignD:
2497     case Op_SignumVF:
2498     case Op_SignumVD:
2499     case Op_SignumF:
2500     case Op_SignumD: {
2501       Node* pair = new BinaryNode(n->in(2), n->in(3));
2502       n->set_req(2, pair);
2503       n->del_req(3);
2504       break;
2505     }
2506     case Op_VectorBlend:
2507     case Op_VectorInsert: {
2508       Node* pair = new BinaryNode(n->in(1), n->in(2));
2509       n->set_req(1, pair);
2510       n->set_req(2, n->in(3));
2511       n->del_req(3);
2512       break;
2513     }
2514     case Op_LoadVectorGatherMasked:
2515     case Op_StoreVectorScatter: {
< prev index next >