< prev index next >

src/hotspot/share/opto/matcher.cpp

Print this page

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
































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

 488   idealreg2mhdebugmask[Op_VecS] = &rms[31];
 489   idealreg2mhdebugmask[Op_VecD] = &rms[32];
 490   idealreg2mhdebugmask[Op_VecX] = &rms[33];
 491   idealreg2mhdebugmask[Op_VecY] = &rms[34];
 492   idealreg2mhdebugmask[Op_VecZ] = &rms[35];
 493 
 494   idealreg2spillmask  [Op_RegVectMask] = &rms[36];
 495   idealreg2debugmask  [Op_RegVectMask] = &rms[37];
 496   idealreg2mhdebugmask[Op_RegVectMask] = &rms[38];
 497 
 498   OptoReg::Name i;
 499 
 500   // At first, start with the empty mask
 501   C->FIRST_STACK_mask().Clear();
 502 
 503   // Add in the incoming argument area
 504   OptoReg::Name init_in = OptoReg::add(_old_SP, C->out_preserve_stack_slots());
 505   for (i = init_in; i < _in_arg_limit; i = OptoReg::add(i,1)) {
 506     C->FIRST_STACK_mask().Insert(i);
 507   }

 508   // Add in all bits past the outgoing argument area
 509   guarantee(RegMask::can_represent_arg(OptoReg::add(_out_arg_limit,-1)),
 510             "must be able to represent all call arguments in reg mask");
 511   OptoReg::Name init = _out_arg_limit;
 512   for (i = init; RegMask::can_represent(i); i = OptoReg::add(i,1)) {
 513     C->FIRST_STACK_mask().Insert(i);
 514   }
 515   // Finally, set the "infinite stack" bit.
 516   C->FIRST_STACK_mask().set_AllStack();
 517 
 518   // Make spill masks.  Registers for their class, plus FIRST_STACK_mask.
 519   RegMask aligned_stack_mask = C->FIRST_STACK_mask();
 520   // Keep spill masks aligned.
 521   aligned_stack_mask.clear_to_pairs();
 522   assert(aligned_stack_mask.is_AllStack(), "should be infinite stack");
 523   RegMask scalable_stack_mask = aligned_stack_mask;
 524 
 525   *idealreg2spillmask[Op_RegP] = *idealreg2regmask[Op_RegP];
 526 #ifdef _LP64
 527   *idealreg2spillmask[Op_RegN] = *idealreg2regmask[Op_RegN];

 729     _register_save_policy[reg] == 'E' ||
 730     _register_save_policy[reg] == 'A'; // Save-on-entry register?
 731 }
 732 
 733 //---------------------------Fixup_Save_On_Entry-------------------------------
 734 void Matcher::Fixup_Save_On_Entry( ) {
 735   init_first_stack_mask();
 736 
 737   Node *root = C->root();       // Short name for root
 738   // Count number of save-on-entry registers.
 739   uint soe_cnt = number_of_saved_registers();
 740   uint i;
 741 
 742   // Find the procedure Start Node
 743   StartNode *start = C->start();
 744   assert( start, "Expect a start node" );
 745 
 746   // Input RegMask array shared by all Returns.
 747   // The type for doubles and longs has a count of 2, but
 748   // there is only 1 returned value
 749   uint ret_edge_cnt = TypeFunc::Parms + ((C->tf()->range()->cnt() == TypeFunc::Parms) ? 0 : 1);
 750   RegMask *ret_rms  = init_input_masks( ret_edge_cnt + soe_cnt, _return_addr_mask, c_frame_ptr_mask );
 751   // Returns have 0 or 1 returned values depending on call signature.
 752   // Return register is specified by return_value in the AD file.
 753   if (ret_edge_cnt > TypeFunc::Parms)
 754     ret_rms[TypeFunc::Parms+0] = _return_value_mask;
 755 
 756   // Input RegMask array shared by all Rethrows.
 757   uint reth_edge_cnt = TypeFunc::Parms+1;
 758   RegMask *reth_rms  = init_input_masks( reth_edge_cnt + soe_cnt, _return_addr_mask, c_frame_ptr_mask );
 759   // Rethrow takes exception oop only, but in the argument 0 slot.
 760   OptoReg::Name reg = find_receiver();
 761   if (reg >= 0) {
 762     reth_rms[TypeFunc::Parms] = mreg2regmask[reg];
 763 #ifdef _LP64
 764     // Need two slots for ptrs in 64-bit land
 765     reth_rms[TypeFunc::Parms].Insert(OptoReg::add(OptoReg::Name(reg), 1));
 766 #endif
 767   }
 768 
 769   // Input RegMask array shared by all TailCalls
 770   uint tail_call_edge_cnt = TypeFunc::Parms+2;
 771   RegMask *tail_call_rms = init_input_masks( tail_call_edge_cnt + soe_cnt, _return_addr_mask, c_frame_ptr_mask );
 772 
 773   // Input RegMask array shared by all TailJumps
 774   uint tail_jump_edge_cnt = TypeFunc::Parms+2;

 801   }
 802 
 803   // Input RegMask array shared by all Halts
 804   uint halt_edge_cnt = TypeFunc::Parms;
 805   RegMask *halt_rms = init_input_masks( halt_edge_cnt + soe_cnt, _return_addr_mask, c_frame_ptr_mask );
 806 
 807   // Capture the return input masks into each exit flavor
 808   for( i=1; i < root->req(); i++ ) {
 809     MachReturnNode *exit = root->in(i)->as_MachReturn();
 810     switch( exit->ideal_Opcode() ) {
 811       case Op_Return   : exit->_in_rms = ret_rms;  break;
 812       case Op_Rethrow  : exit->_in_rms = reth_rms; break;
 813       case Op_TailCall : exit->_in_rms = tail_call_rms; break;
 814       case Op_TailJump : exit->_in_rms = tail_jump_rms; break;
 815       case Op_Halt     : exit->_in_rms = halt_rms; break;
 816       default          : ShouldNotReachHere();
 817     }
 818   }
 819 
 820   // Next unused projection number from Start.
 821   int proj_cnt = C->tf()->domain()->cnt();
 822 
 823   // Do all the save-on-entry registers.  Make projections from Start for
 824   // them, and give them a use at the exit points.  To the allocator, they
 825   // look like incoming register arguments.
 826   for( i = 0; i < _last_Mach_Reg; i++ ) {
 827     if( is_save_on_entry(i) ) {
 828 
 829       // Add the save-on-entry to the mask array
 830       ret_rms      [      ret_edge_cnt] = mreg2regmask[i];
 831       reth_rms     [     reth_edge_cnt] = mreg2regmask[i];
 832       tail_call_rms[tail_call_edge_cnt] = mreg2regmask[i];
 833       tail_jump_rms[tail_jump_edge_cnt] = mreg2regmask[i];
 834       // Halts need the SOE registers, but only in the stack as debug info.
 835       // A just-prior uncommon-trap or deoptimization will use the SOE regs.
 836       halt_rms     [     halt_edge_cnt] = *idealreg2spillmask[_register_save_type[i]];
 837 
 838       Node *mproj;
 839 
 840       // Is this a RegF low half of a RegD?  Double up 2 adjacent RegF's
 841       // into a single RegD.

1073       Node *oldn = n;
1074       // Old-space or new-space check
1075       if (!C->node_arena()->contains(n)) {
1076         // Old space!
1077         Node* m;
1078         if (has_new_node(n)) {  // Not yet Label/Reduced
1079           m = new_node(n);
1080         } else {
1081           if (!is_dontcare(n)) { // Matcher can match this guy
1082             // Calls match special.  They match alone with no children.
1083             // Their children, the incoming arguments, match normally.
1084             m = n->is_SafePoint() ? match_sfpt(n->as_SafePoint()):match_tree(n);
1085             if (C->failing())  return NULL;
1086             if (m == NULL) { Matcher::soft_match_failure(); return NULL; }
1087             if (n->is_MemBar()) {
1088               m->as_MachMemBar()->set_adr_type(n->adr_type());
1089             }
1090           } else {                  // Nothing the matcher cares about
1091             if (n->is_Proj() && n->in(0) != NULL && n->in(0)->is_Multi()) {       // Projections?
1092               // Convert to machine-dependent projection
1093               m = n->in(0)->as_Multi()->match( n->as_Proj(), this );




1094               NOT_PRODUCT(record_new2old(m, n);)
1095               if (m->in(0) != NULL) // m might be top
1096                 collect_null_checks(m, n);
1097             } else {                // Else just a regular 'ol guy
1098               m = n->clone();       // So just clone into new-space
1099               NOT_PRODUCT(record_new2old(m, n);)
1100               // Def-Use edges will be added incrementally as Uses
1101               // of this node are matched.
1102               assert(m->outcnt() == 0, "no Uses of this clone yet");
1103             }
1104           }
1105 
1106           set_new_node(n, m);       // Map old to new
1107           if (_old_node_note_array != NULL) {
1108             Node_Notes* nn = C->locate_node_notes(_old_node_note_array,
1109                                                   n->_idx);
1110             C->set_node_notes_at(m->_idx, nn);
1111           }
1112           debug_only(match_alias_type(C, n, m));
1113         }

1212   }
1213   return OptoReg::as_OptoReg(reg);
1214 }
1215 
1216 
1217 //------------------------------match_sfpt-------------------------------------
1218 // Helper function to match call instructions.  Calls match special.
1219 // They match alone with no children.  Their children, the incoming
1220 // arguments, match normally.
1221 MachNode *Matcher::match_sfpt( SafePointNode *sfpt ) {
1222   MachSafePointNode *msfpt = NULL;
1223   MachCallNode      *mcall = NULL;
1224   uint               cnt;
1225   // Split out case for SafePoint vs Call
1226   CallNode *call;
1227   const TypeTuple *domain;
1228   ciMethod*        method = NULL;
1229   bool             is_method_handle_invoke = false;  // for special kill effects
1230   if( sfpt->is_Call() ) {
1231     call = sfpt->as_Call();
1232     domain = call->tf()->domain();
1233     cnt = domain->cnt();
1234 
1235     // Match just the call, nothing else
1236     MachNode *m = match_tree(call);
1237     if (C->failing())  return NULL;
1238     if( m == NULL ) { Matcher::soft_match_failure(); return NULL; }
1239 
1240     // Copy data from the Ideal SafePoint to the machine version
1241     mcall = m->as_MachCall();
1242 
1243     mcall->set_tf(                  call->tf());
1244     mcall->set_entry_point(         call->entry_point());
1245     mcall->set_cnt(                 call->cnt());
1246     mcall->set_guaranteed_safepoint(call->guaranteed_safepoint());
1247 
1248     if( mcall->is_MachCallJava() ) {
1249       MachCallJavaNode *mcall_java  = mcall->as_MachCallJava();
1250       const CallJavaNode *call_java =  call->as_CallJava();
1251       assert(call_java->validate_symbolic_info(), "inconsistent info");
1252       method = call_java->method();

1300   for (uint i = 0; i < cnt; i++) ::new (&(msfpt->_in_rms[i])) RegMask();
1301 
1302   // Do all the pre-defined non-Empty register masks
1303   msfpt->_in_rms[TypeFunc::ReturnAdr] = _return_addr_mask;
1304   msfpt->_in_rms[TypeFunc::FramePtr ] = c_frame_ptr_mask;
1305 
1306   // Place first outgoing argument can possibly be put.
1307   OptoReg::Name begin_out_arg_area = OptoReg::add(_new_SP, C->out_preserve_stack_slots());
1308   assert( is_even(begin_out_arg_area), "" );
1309   // Compute max outgoing register number per call site.
1310   OptoReg::Name out_arg_limit_per_call = begin_out_arg_area;
1311   // Calls to C may hammer extra stack slots above and beyond any arguments.
1312   // These are usually backing store for register arguments for varargs.
1313   if( call != NULL && call->is_CallRuntime() )
1314     out_arg_limit_per_call = OptoReg::add(out_arg_limit_per_call,C->varargs_C_out_slots_killed());
1315   if( call != NULL && call->is_CallNative() )
1316     out_arg_limit_per_call = OptoReg::add(out_arg_limit_per_call, call->as_CallNative()->_shadow_space_bytes);
1317 
1318 
1319   // Do the normal argument list (parameters) register masks
1320   int argcnt = cnt - TypeFunc::Parms;



1321   if( argcnt > 0 ) {          // Skip it all if we have no args
1322     BasicType *sig_bt  = NEW_RESOURCE_ARRAY( BasicType, argcnt );
1323     VMRegPair *parm_regs = NEW_RESOURCE_ARRAY( VMRegPair, argcnt );
1324     int i;
1325     for( i = 0; i < argcnt; i++ ) {
1326       sig_bt[i] = domain->field_at(i+TypeFunc::Parms)->basic_type();
1327     }
1328     // V-call to pick proper calling convention
1329     call->calling_convention( sig_bt, parm_regs, argcnt );
1330 
1331 #ifdef ASSERT
1332     // Sanity check users' calling convention.  Really handy during
1333     // the initial porting effort.  Fairly expensive otherwise.
1334     { for (int i = 0; i<argcnt; i++) {
1335       if( !parm_regs[i].first()->is_valid() &&
1336           !parm_regs[i].second()->is_valid() ) continue;
1337       VMReg reg1 = parm_regs[i].first();
1338       VMReg reg2 = parm_regs[i].second();
1339       for (int j = 0; j < i; j++) {
1340         if( !parm_regs[j].first()->is_valid() &&
1341             !parm_regs[j].second()->is_valid() ) continue;
1342         VMReg reg3 = parm_regs[j].first();
1343         VMReg reg4 = parm_regs[j].second();
1344         if( !reg1->is_valid() ) {
1345           assert( !reg2->is_valid(), "valid halvsies" );
1346         } else if( !reg3->is_valid() ) {
1347           assert( !reg4->is_valid(), "valid halvsies" );
1348         } else {
1349           assert( reg1 != reg2, "calling conv. must produce distinct regs");
1350           assert( reg1 != reg3, "calling conv. must produce distinct regs");
1351           assert( reg1 != reg4, "calling conv. must produce distinct regs");
1352           assert( reg2 != reg3, "calling conv. must produce distinct regs");
1353           assert( reg2 != reg4 || !reg2->is_valid(), "calling conv. must produce distinct regs");
1354           assert( reg3 != reg4, "calling conv. must produce distinct regs");
1355         }
1356       }
1357     }
1358     }
1359 #endif
1360 
1361     // Visit each argument.  Compute its outgoing register mask.
1362     // Return results now can have 2 bits returned.
1363     // Compute max over all outgoing arguments both per call-site
1364     // and over the entire method.
1365     for( i = 0; i < argcnt; i++ ) {
1366       // Address of incoming argument mask to fill in
1367       RegMask *rm = &mcall->_in_rms[i+TypeFunc::Parms];
1368       VMReg first = parm_regs[i].first();
1369       VMReg second = parm_regs[i].second();
1370       if(!first->is_valid() &&
1371          !second->is_valid()) {
1372         continue;               // Avoid Halves
1373       }
1374       // Handle case where arguments are in vector registers.
1375       if(call->in(TypeFunc::Parms + i)->bottom_type()->isa_vect()) {
1376         OptoReg::Name reg_fst = OptoReg::as_OptoReg(first);
1377         OptoReg::Name reg_snd = OptoReg::as_OptoReg(second);
1378         assert (reg_fst <= reg_snd, "fst=%d snd=%d", reg_fst, reg_snd);
1379         for (OptoReg::Name r = reg_fst; r <= reg_snd; r++) {
1380           rm->Insert(r);
1381         }
1382       }
1383       // Grab first register, adjust stack slots and insert in mask.
1384       OptoReg::Name reg1 = warp_outgoing_stk_arg(first, begin_out_arg_area, out_arg_limit_per_call );
1385       if (OptoReg::is_valid(reg1))
1386         rm->Insert( reg1 );

1387       // Grab second register (if any), adjust stack slots and insert in mask.
1388       OptoReg::Name reg2 = warp_outgoing_stk_arg(second, begin_out_arg_area, out_arg_limit_per_call );
1389       if (OptoReg::is_valid(reg2))
1390         rm->Insert( reg2 );

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

2090         set_shared(n);       // Flag as shared and
2091         if (n->is_DecodeNarrowPtr()) {
2092           // Oop field/array element loads must be shared but since
2093           // they are shared through a DecodeN they may appear to have
2094           // a single use so force sharing here.
2095           set_shared(n->in(1));
2096         }
2097         mstack.pop();        // remove node from stack
2098         continue;
2099       }
2100       nstate = Visit; // Not already visited; so visit now
2101     }
2102     if (nstate == Visit) {
2103       mstack.set_state(Post_Visit);
2104       set_visited(n);   // Flag as visited now
2105       bool mem_op = false;
2106       int mem_addr_idx = MemNode::Address;
2107       if (find_shared_visit(mstack, n, nop, mem_op, mem_addr_idx)) {
2108         continue;
2109       }
2110       for (int i = n->req() - 1; i >= 0; --i) { // For my children
2111         Node* m = n->in(i); // Get ith input
2112         if (m == NULL) {
2113           continue;  // Ignore NULLs
2114         }
2115         if (clone_node(n, m, mstack)) {
2116           continue;
2117         }
2118 
2119         // Clone addressing expressions as they are "free" in memory access instructions
2120         if (mem_op && i == mem_addr_idx && m->is_AddP() &&
2121             // When there are other uses besides address expressions
2122             // put it on stack and mark as shared.
2123             !is_visited(m)) {
2124           // Some inputs for address expression are not put on stack
2125           // to avoid marking them as shared and forcing them into register
2126           // if they are used only in address expressions.
2127           // But they should be marked as shared if there are other uses
2128           // besides address expressions.
2129 
2130           if (pd_clone_address_expressions(m->as_AddP(), mstack, address_visited)) {

2379     case Op_FmaD:
2380     case Op_FmaF:
2381     case Op_FmaVD:
2382     case Op_FmaVF: {
2383       // Restructure into a binary tree for Matching.
2384       Node* pair = new BinaryNode(n->in(1), n->in(2));
2385       n->set_req(2, pair);
2386       n->set_req(1, n->in(3));
2387       n->del_req(3);
2388       break;
2389     }
2390     case Op_MulAddS2I: {
2391       Node* pair1 = new BinaryNode(n->in(1), n->in(2));
2392       Node* pair2 = new BinaryNode(n->in(3), n->in(4));
2393       n->set_req(1, pair1);
2394       n->set_req(2, pair2);
2395       n->del_req(4);
2396       n->del_req(3);
2397       break;
2398     }







2399     case Op_CopySignD:
2400     case Op_SignumF:
2401     case Op_SignumD: {
2402       Node* pair = new BinaryNode(n->in(2), n->in(3));
2403       n->set_req(2, pair);
2404       n->del_req(3);
2405       break;
2406     }
2407     case Op_VectorBlend:
2408     case Op_VectorInsert: {
2409       Node* pair = new BinaryNode(n->in(1), n->in(2));
2410       n->set_req(1, pair);
2411       n->set_req(2, n->in(3));
2412       n->del_req(3);
2413       break;
2414     }
2415     case Op_StoreVectorScatter: {
2416       Node* pair = new BinaryNode(n->in(MemNode::ValueIn), n->in(MemNode::ValueIn+1));
2417       n->set_req(MemNode::ValueIn, pair);
2418       n->del_req(MemNode::ValueIn+1);

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











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

 509   idealreg2mhdebugmask[Op_VecS] = &rms[31];
 510   idealreg2mhdebugmask[Op_VecD] = &rms[32];
 511   idealreg2mhdebugmask[Op_VecX] = &rms[33];
 512   idealreg2mhdebugmask[Op_VecY] = &rms[34];
 513   idealreg2mhdebugmask[Op_VecZ] = &rms[35];
 514 
 515   idealreg2spillmask  [Op_RegVectMask] = &rms[36];
 516   idealreg2debugmask  [Op_RegVectMask] = &rms[37];
 517   idealreg2mhdebugmask[Op_RegVectMask] = &rms[38];
 518 
 519   OptoReg::Name i;
 520 
 521   // At first, start with the empty mask
 522   C->FIRST_STACK_mask().Clear();
 523 
 524   // Add in the incoming argument area
 525   OptoReg::Name init_in = OptoReg::add(_old_SP, C->out_preserve_stack_slots());
 526   for (i = init_in; i < _in_arg_limit; i = OptoReg::add(i,1)) {
 527     C->FIRST_STACK_mask().Insert(i);
 528   }
 529 
 530   // Add in all bits past the outgoing argument area
 531   guarantee(RegMask::can_represent_arg(OptoReg::add(_out_arg_limit,-1)),
 532             "must be able to represent all call arguments in reg mask");
 533   OptoReg::Name init = _out_arg_limit;
 534   for (i = init; RegMask::can_represent(i); i = OptoReg::add(i,1)) {
 535     C->FIRST_STACK_mask().Insert(i);
 536   }
 537   // Finally, set the "infinite stack" bit.
 538   C->FIRST_STACK_mask().set_AllStack();
 539 
 540   // Make spill masks.  Registers for their class, plus FIRST_STACK_mask.
 541   RegMask aligned_stack_mask = C->FIRST_STACK_mask();
 542   // Keep spill masks aligned.
 543   aligned_stack_mask.clear_to_pairs();
 544   assert(aligned_stack_mask.is_AllStack(), "should be infinite stack");
 545   RegMask scalable_stack_mask = aligned_stack_mask;
 546 
 547   *idealreg2spillmask[Op_RegP] = *idealreg2regmask[Op_RegP];
 548 #ifdef _LP64
 549   *idealreg2spillmask[Op_RegN] = *idealreg2regmask[Op_RegN];

 751     _register_save_policy[reg] == 'E' ||
 752     _register_save_policy[reg] == 'A'; // Save-on-entry register?
 753 }
 754 
 755 //---------------------------Fixup_Save_On_Entry-------------------------------
 756 void Matcher::Fixup_Save_On_Entry( ) {
 757   init_first_stack_mask();
 758 
 759   Node *root = C->root();       // Short name for root
 760   // Count number of save-on-entry registers.
 761   uint soe_cnt = number_of_saved_registers();
 762   uint i;
 763 
 764   // Find the procedure Start Node
 765   StartNode *start = C->start();
 766   assert( start, "Expect a start node" );
 767 
 768   // Input RegMask array shared by all Returns.
 769   // The type for doubles and longs has a count of 2, but
 770   // there is only 1 returned value
 771   uint ret_edge_cnt = C->tf()->range_cc()->cnt();
 772   RegMask *ret_rms  = init_input_masks( ret_edge_cnt + soe_cnt, _return_addr_mask, c_frame_ptr_mask );
 773   for (i = TypeFunc::Parms; i < ret_edge_cnt; i++) {
 774     ret_rms[i] = _return_values_mask[i-TypeFunc::Parms];
 775   }

 776 
 777   // Input RegMask array shared by all Rethrows.
 778   uint reth_edge_cnt = TypeFunc::Parms+1;
 779   RegMask *reth_rms  = init_input_masks( reth_edge_cnt + soe_cnt, _return_addr_mask, c_frame_ptr_mask );
 780   // Rethrow takes exception oop only, but in the argument 0 slot.
 781   OptoReg::Name reg = find_receiver();
 782   if (reg >= 0) {
 783     reth_rms[TypeFunc::Parms] = mreg2regmask[reg];
 784 #ifdef _LP64
 785     // Need two slots for ptrs in 64-bit land
 786     reth_rms[TypeFunc::Parms].Insert(OptoReg::add(OptoReg::Name(reg), 1));
 787 #endif
 788   }
 789 
 790   // Input RegMask array shared by all TailCalls
 791   uint tail_call_edge_cnt = TypeFunc::Parms+2;
 792   RegMask *tail_call_rms = init_input_masks( tail_call_edge_cnt + soe_cnt, _return_addr_mask, c_frame_ptr_mask );
 793 
 794   // Input RegMask array shared by all TailJumps
 795   uint tail_jump_edge_cnt = TypeFunc::Parms+2;

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

1094       Node *oldn = n;
1095       // Old-space or new-space check
1096       if (!C->node_arena()->contains(n)) {
1097         // Old space!
1098         Node* m;
1099         if (has_new_node(n)) {  // Not yet Label/Reduced
1100           m = new_node(n);
1101         } else {
1102           if (!is_dontcare(n)) { // Matcher can match this guy
1103             // Calls match special.  They match alone with no children.
1104             // Their children, the incoming arguments, match normally.
1105             m = n->is_SafePoint() ? match_sfpt(n->as_SafePoint()):match_tree(n);
1106             if (C->failing())  return NULL;
1107             if (m == NULL) { Matcher::soft_match_failure(); return NULL; }
1108             if (n->is_MemBar()) {
1109               m->as_MachMemBar()->set_adr_type(n->adr_type());
1110             }
1111           } else {                  // Nothing the matcher cares about
1112             if (n->is_Proj() && n->in(0) != NULL && n->in(0)->is_Multi()) {       // Projections?
1113               // Convert to machine-dependent projection
1114               RegMask* mask = NULL;
1115               if (n->in(0)->is_Call() && n->in(0)->as_Call()->tf()->returns_inline_type_as_fields()) {
1116                 mask = return_values_mask(n->in(0)->as_Call()->tf()->range_cc());
1117               }
1118               m = n->in(0)->as_Multi()->match(n->as_Proj(), this, mask);
1119               NOT_PRODUCT(record_new2old(m, n);)
1120               if (m->in(0) != NULL) // m might be top
1121                 collect_null_checks(m, n);
1122             } else {                // Else just a regular 'ol guy
1123               m = n->clone();       // So just clone into new-space
1124               NOT_PRODUCT(record_new2old(m, n);)
1125               // Def-Use edges will be added incrementally as Uses
1126               // of this node are matched.
1127               assert(m->outcnt() == 0, "no Uses of this clone yet");
1128             }
1129           }
1130 
1131           set_new_node(n, m);       // Map old to new
1132           if (_old_node_note_array != NULL) {
1133             Node_Notes* nn = C->locate_node_notes(_old_node_note_array,
1134                                                   n->_idx);
1135             C->set_node_notes_at(m->_idx, nn);
1136           }
1137           debug_only(match_alias_type(C, n, m));
1138         }

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

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

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

2409     case Op_FmaD:
2410     case Op_FmaF:
2411     case Op_FmaVD:
2412     case Op_FmaVF: {
2413       // Restructure into a binary tree for Matching.
2414       Node* pair = new BinaryNode(n->in(1), n->in(2));
2415       n->set_req(2, pair);
2416       n->set_req(1, n->in(3));
2417       n->del_req(3);
2418       break;
2419     }
2420     case Op_MulAddS2I: {
2421       Node* pair1 = new BinaryNode(n->in(1), n->in(2));
2422       Node* pair2 = new BinaryNode(n->in(3), n->in(4));
2423       n->set_req(1, pair1);
2424       n->set_req(2, pair2);
2425       n->del_req(4);
2426       n->del_req(3);
2427       break;
2428     }
2429     case Op_ClearArray: {
2430       Node* pair = new BinaryNode(n->in(2), n->in(3));
2431       n->set_req(2, pair);
2432       n->set_req(3, n->in(4));
2433       n->del_req(4);
2434       break;
2435     }
2436     case Op_CopySignD:
2437     case Op_SignumF:
2438     case Op_SignumD: {
2439       Node* pair = new BinaryNode(n->in(2), n->in(3));
2440       n->set_req(2, pair);
2441       n->del_req(3);
2442       break;
2443     }
2444     case Op_VectorBlend:
2445     case Op_VectorInsert: {
2446       Node* pair = new BinaryNode(n->in(1), n->in(2));
2447       n->set_req(1, pair);
2448       n->set_req(2, n->in(3));
2449       n->del_req(3);
2450       break;
2451     }
2452     case Op_StoreVectorScatter: {
2453       Node* pair = new BinaryNode(n->in(MemNode::ValueIn), n->in(MemNode::ValueIn+1));
2454       n->set_req(MemNode::ValueIn, pair);
2455       n->del_req(MemNode::ValueIn+1);
< prev index next >