< prev index next >

src/hotspot/share/opto/matcher.cpp

Print this page

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












































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

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

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

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

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

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




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

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

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



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

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

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

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

2439     case Op_FmaD:
2440     case Op_FmaF:
2441     case Op_FmaVD:
2442     case Op_FmaVF: {
2443       // Restructure into a binary tree for Matching.
2444       Node* pair = new BinaryNode(n->in(1), n->in(2));
2445       n->set_req(2, pair);
2446       n->set_req(1, n->in(3));
2447       n->del_req(3);
2448       break;
2449     }
2450     case Op_MulAddS2I: {
2451       Node* pair1 = new BinaryNode(n->in(1), n->in(2));
2452       Node* pair2 = new BinaryNode(n->in(3), n->in(4));
2453       n->set_req(1, pair1);
2454       n->set_req(2, pair2);
2455       n->del_req(4);
2456       n->del_req(3);
2457       break;
2458     }







2459     case Op_VectorCmpMasked:
2460     case Op_CopySignD:
2461     case Op_SignumVF:
2462     case Op_SignumVD:
2463     case Op_SignumF:
2464     case Op_SignumD: {
2465       Node* pair = new BinaryNode(n->in(2), n->in(3));
2466       n->set_req(2, pair);
2467       n->del_req(3);
2468       break;
2469     }
2470     case Op_VectorBlend:
2471     case Op_VectorInsert: {
2472       Node* pair = new BinaryNode(n->in(1), n->in(2));
2473       n->set_req(1, pair);
2474       n->set_req(2, n->in(3));
2475       n->del_req(3);
2476       break;
2477     }
2478     case Op_LoadVectorGatherMasked:

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












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

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

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

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

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

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

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

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

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

2480     case Op_FmaD:
2481     case Op_FmaF:
2482     case Op_FmaVD:
2483     case Op_FmaVF: {
2484       // Restructure into a binary tree for Matching.
2485       Node* pair = new BinaryNode(n->in(1), n->in(2));
2486       n->set_req(2, pair);
2487       n->set_req(1, n->in(3));
2488       n->del_req(3);
2489       break;
2490     }
2491     case Op_MulAddS2I: {
2492       Node* pair1 = new BinaryNode(n->in(1), n->in(2));
2493       Node* pair2 = new BinaryNode(n->in(3), n->in(4));
2494       n->set_req(1, pair1);
2495       n->set_req(2, pair2);
2496       n->del_req(4);
2497       n->del_req(3);
2498       break;
2499     }
2500     case Op_ClearArray: {
2501       Node* pair = new BinaryNode(n->in(2), n->in(3));
2502       n->set_req(2, pair);
2503       n->set_req(3, n->in(4));
2504       n->del_req(4);
2505       break;
2506     }
2507     case Op_VectorCmpMasked:
2508     case Op_CopySignD:
2509     case Op_SignumVF:
2510     case Op_SignumVD:
2511     case Op_SignumF:
2512     case Op_SignumD: {
2513       Node* pair = new BinaryNode(n->in(2), n->in(3));
2514       n->set_req(2, pair);
2515       n->del_req(3);
2516       break;
2517     }
2518     case Op_VectorBlend:
2519     case Op_VectorInsert: {
2520       Node* pair = new BinaryNode(n->in(1), n->in(2));
2521       n->set_req(1, pair);
2522       n->set_req(2, n->in(3));
2523       n->del_req(3);
2524       break;
2525     }
2526     case Op_LoadVectorGatherMasked:
< prev index next >