< prev index next >

src/hotspot/share/opto/matcher.cpp

Print this page

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












































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

 518   idealreg2mhdebugmask[Op_VecS] = &rms[31];
 519   idealreg2mhdebugmask[Op_VecD] = &rms[32];
 520   idealreg2mhdebugmask[Op_VecX] = &rms[33];
 521   idealreg2mhdebugmask[Op_VecY] = &rms[34];
 522   idealreg2mhdebugmask[Op_VecZ] = &rms[35];
 523 
 524   idealreg2spillmask  [Op_RegVectMask] = &rms[36];
 525   idealreg2debugmask  [Op_RegVectMask] = &rms[37];
 526   idealreg2mhdebugmask[Op_RegVectMask] = &rms[38];
 527 
 528   OptoReg::Name i;
 529 
 530   // At first, start with the empty mask
 531   C->FIRST_STACK_mask().Clear();
 532 
 533   // Add in the incoming argument area
 534   OptoReg::Name init_in = OptoReg::add(_old_SP, C->out_preserve_stack_slots());
 535   for (i = init_in; i < _in_arg_limit; i = OptoReg::add(i,1)) {
 536     C->FIRST_STACK_mask().Insert(i);
 537   }

 538   // Add in all bits past the outgoing argument area
 539   guarantee(RegMask::can_represent_arg(OptoReg::add(_out_arg_limit,-1)),
 540             "must be able to represent all call arguments in reg mask");
 541   OptoReg::Name init = _out_arg_limit;
 542   for (i = init; RegMask::can_represent(i); i = OptoReg::add(i,1)) {
 543     C->FIRST_STACK_mask().Insert(i);
 544   }
 545   // Finally, set the "infinite stack" bit.
 546   C->FIRST_STACK_mask().set_AllStack();
 547 
 548   // Make spill masks.  Registers for their class, plus FIRST_STACK_mask.
 549   RegMask aligned_stack_mask = C->FIRST_STACK_mask();
 550   // Keep spill masks aligned.
 551   aligned_stack_mask.clear_to_pairs();
 552   assert(aligned_stack_mask.is_AllStack(), "should be infinite stack");
 553   RegMask scalable_stack_mask = aligned_stack_mask;
 554 
 555   *idealreg2spillmask[Op_RegP] = *idealreg2regmask[Op_RegP];
 556 #ifdef _LP64
 557   *idealreg2spillmask[Op_RegN] = *idealreg2regmask[Op_RegN];

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

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

1121       Node *oldn = n;
1122       // Old-space or new-space check
1123       if (!C->node_arena()->contains(n)) {
1124         // Old space!
1125         Node* m;
1126         if (has_new_node(n)) {  // Not yet Label/Reduced
1127           m = new_node(n);
1128         } else {
1129           if (!is_dontcare(n)) { // Matcher can match this guy
1130             // Calls match special.  They match alone with no children.
1131             // Their children, the incoming arguments, match normally.
1132             m = n->is_SafePoint() ? match_sfpt(n->as_SafePoint()):match_tree(n);
1133             if (C->failing())  return nullptr;
1134             if (m == nullptr) { Matcher::soft_match_failure(); return nullptr; }
1135             if (n->is_MemBar()) {
1136               m->as_MachMemBar()->set_adr_type(n->adr_type());
1137             }
1138           } else {                  // Nothing the matcher cares about
1139             if (n->is_Proj() && n->in(0) != nullptr && n->in(0)->is_Multi()) {       // Projections?
1140               // Convert to machine-dependent projection
1141               m = n->in(0)->as_Multi()->match( n->as_Proj(), this );




1142               NOT_PRODUCT(record_new2old(m, n);)
1143               if (m->in(0) != nullptr) // m might be top
1144                 collect_null_checks(m, n);
1145             } else {                // Else just a regular 'ol guy
1146               m = n->clone();       // So just clone into new-space
1147               NOT_PRODUCT(record_new2old(m, n);)
1148               // Def-Use edges will be added incrementally as Uses
1149               // of this node are matched.
1150               assert(m->outcnt() == 0, "no Uses of this clone yet");
1151             }
1152           }
1153 
1154           set_new_node(n, m);       // Map old to new
1155           if (_old_node_note_array != nullptr) {
1156             Node_Notes* nn = C->locate_node_notes(_old_node_note_array,
1157                                                   n->_idx);
1158             C->set_node_notes_at(m->_idx, nn);
1159           }
1160           debug_only(match_alias_type(C, n, m));
1161         }

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

1340   msfpt->_in_rms = NEW_RESOURCE_ARRAY( RegMask, cnt );
1341   // Empty them all.
1342   for (uint i = 0; i < cnt; i++) ::new (&(msfpt->_in_rms[i])) RegMask();
1343 
1344   // Do all the pre-defined non-Empty register masks
1345   msfpt->_in_rms[TypeFunc::ReturnAdr] = _return_addr_mask;
1346   msfpt->_in_rms[TypeFunc::FramePtr ] = c_frame_ptr_mask;
1347 
1348   // Place first outgoing argument can possibly be put.
1349   OptoReg::Name begin_out_arg_area = OptoReg::add(_new_SP, C->out_preserve_stack_slots());
1350   assert( is_even(begin_out_arg_area), "" );
1351   // Compute max outgoing register number per call site.
1352   OptoReg::Name out_arg_limit_per_call = begin_out_arg_area;
1353   // Calls to C may hammer extra stack slots above and beyond any arguments.
1354   // These are usually backing store for register arguments for varargs.
1355   if( call != nullptr && call->is_CallRuntime() )
1356     out_arg_limit_per_call = OptoReg::add(out_arg_limit_per_call,C->varargs_C_out_slots_killed());
1357 
1358 
1359   // Do the normal argument list (parameters) register masks
1360   int argcnt = cnt - TypeFunc::Parms;



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

1427       // Grab second register (if any), adjust stack slots and insert in mask.
1428       OptoReg::Name reg2 = warp_outgoing_stk_arg(second, begin_out_arg_area, out_arg_limit_per_call );
1429       if (OptoReg::is_valid(reg2))
1430         rm->Insert( reg2 );

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

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

2452     case Op_FmaD:
2453     case Op_FmaF:
2454     case Op_FmaVD:
2455     case Op_FmaVF: {
2456       // Restructure into a binary tree for Matching.
2457       Node* pair = new BinaryNode(n->in(1), n->in(2));
2458       n->set_req(2, pair);
2459       n->set_req(1, n->in(3));
2460       n->del_req(3);
2461       break;
2462     }
2463     case Op_MulAddS2I: {
2464       Node* pair1 = new BinaryNode(n->in(1), n->in(2));
2465       Node* pair2 = new BinaryNode(n->in(3), n->in(4));
2466       n->set_req(1, pair1);
2467       n->set_req(2, pair2);
2468       n->del_req(4);
2469       n->del_req(3);
2470       break;
2471     }







2472     case Op_VectorCmpMasked:
2473     case Op_CopySignD:
2474     case Op_SignumVF:
2475     case Op_SignumVD:
2476     case Op_SignumF:
2477     case Op_SignumD: {
2478       Node* pair = new BinaryNode(n->in(2), n->in(3));
2479       n->set_req(2, pair);
2480       n->del_req(3);
2481       break;
2482     }
2483     case Op_VectorBlend:
2484     case Op_VectorInsert: {
2485       Node* pair = new BinaryNode(n->in(1), n->in(2));
2486       n->set_req(1, pair);
2487       n->set_req(2, n->in(3));
2488       n->del_req(3);
2489       break;
2490     }
2491     case Op_LoadVectorGatherMasked:

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












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

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

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

 834 
 835   // Input RegMask array shared by all Rethrows.
 836   uint reth_edge_cnt = TypeFunc::Parms+1;
 837   RegMask *reth_rms  = init_input_masks( reth_edge_cnt + soe_cnt, _return_addr_mask, c_frame_ptr_mask );
 838   // Rethrow takes exception oop only, but in the argument 0 slot.
 839   OptoReg::Name reg = find_receiver();
 840   if (reg >= 0) {
 841     reth_rms[TypeFunc::Parms] = mreg2regmask[reg];
 842 #ifdef _LP64
 843     // Need two slots for ptrs in 64-bit land
 844     reth_rms[TypeFunc::Parms].Insert(OptoReg::add(OptoReg::Name(reg), 1));
 845 #endif
 846   }
 847 
 848   // Input RegMask array shared by all TailCalls
 849   uint tail_call_edge_cnt = TypeFunc::Parms+2;
 850   RegMask *tail_call_rms = init_input_masks( tail_call_edge_cnt + soe_cnt, _return_addr_mask, c_frame_ptr_mask );
 851 
 852   // Input RegMask array shared by all TailJumps
 853   uint tail_jump_edge_cnt = TypeFunc::Parms+2;

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

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

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

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

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

2493     case Op_FmaD:
2494     case Op_FmaF:
2495     case Op_FmaVD:
2496     case Op_FmaVF: {
2497       // Restructure into a binary tree for Matching.
2498       Node* pair = new BinaryNode(n->in(1), n->in(2));
2499       n->set_req(2, pair);
2500       n->set_req(1, n->in(3));
2501       n->del_req(3);
2502       break;
2503     }
2504     case Op_MulAddS2I: {
2505       Node* pair1 = new BinaryNode(n->in(1), n->in(2));
2506       Node* pair2 = new BinaryNode(n->in(3), n->in(4));
2507       n->set_req(1, pair1);
2508       n->set_req(2, pair2);
2509       n->del_req(4);
2510       n->del_req(3);
2511       break;
2512     }
2513     case Op_ClearArray: {
2514       Node* pair = new BinaryNode(n->in(2), n->in(3));
2515       n->set_req(2, pair);
2516       n->set_req(3, n->in(4));
2517       n->del_req(4);
2518       break;
2519     }
2520     case Op_VectorCmpMasked:
2521     case Op_CopySignD:
2522     case Op_SignumVF:
2523     case Op_SignumVD:
2524     case Op_SignumF:
2525     case Op_SignumD: {
2526       Node* pair = new BinaryNode(n->in(2), n->in(3));
2527       n->set_req(2, pair);
2528       n->del_req(3);
2529       break;
2530     }
2531     case Op_VectorBlend:
2532     case Op_VectorInsert: {
2533       Node* pair = new BinaryNode(n->in(1), n->in(2));
2534       n->set_req(1, pair);
2535       n->set_req(2, n->in(3));
2536       n->del_req(3);
2537       break;
2538     }
2539     case Op_LoadVectorGatherMasked:
< prev index next >