166 Unique_Node_List worklist;
167 VectorSet visited;
168 worklist.push(xroot);
169 while (worklist.size() > 0) {
170 Node* n = worklist.pop();
171 visited.set(n->_idx);
172 assert(C->node_arena()->contains(n), "dead node");
173 for (uint j = 0; j < n->req(); j++) {
174 Node* in = n->in(j);
175 if (in != NULL) {
176 assert(C->node_arena()->contains(in), "dead node");
177 if (!visited.test(in->_idx)) {
178 worklist.push(in);
179 }
180 }
181 }
182 }
183 }
184 #endif
185
186
187 //---------------------------match---------------------------------------------
188 void Matcher::match( ) {
189 if( MaxLabelRootDepth < 100 ) { // Too small?
190 assert(false, "invalid MaxLabelRootDepth, increase it to 100 minimum");
191 MaxLabelRootDepth = 100;
192 }
193 // One-time initialization of some register masks.
194 init_spill_mask( C->root()->in(1) );
195 _return_addr_mask = return_addr();
196 #ifdef _LP64
197 // Pointers take 2 slots in 64-bit land
198 _return_addr_mask.Insert(OptoReg::add(return_addr(),1));
199 #endif
200
201 // Map a Java-signature return type into return register-value
202 // machine registers for 0, 1 and 2 returned values.
203 const TypeTuple *range = C->tf()->range();
204 if( range->cnt() > TypeFunc::Parms ) { // If not a void function
205 // Get ideal-register return type
206 uint ireg = range->field_at(TypeFunc::Parms)->ideal_reg();
207 // Get machine return register
208 uint sop = C->start()->Opcode();
209 OptoRegPair regs = return_value(ireg);
210
211 // And mask for same
212 _return_value_mask = RegMask(regs.first());
213 if( OptoReg::is_valid(regs.second()) )
214 _return_value_mask.Insert(regs.second());
215 }
216
217 // ---------------
218 // Frame Layout
219
220 // Need the method signature to determine the incoming argument types,
221 // because the types determine which registers the incoming arguments are
222 // in, and this affects the matched code.
223 const TypeTuple *domain = C->tf()->domain();
224 uint argcnt = domain->cnt() - TypeFunc::Parms;
225 BasicType *sig_bt = NEW_RESOURCE_ARRAY( BasicType, argcnt );
226 VMRegPair *vm_parm_regs = NEW_RESOURCE_ARRAY( VMRegPair, argcnt );
227 _parm_regs = NEW_RESOURCE_ARRAY( OptoRegPair, argcnt );
228 _calling_convention_mask = NEW_RESOURCE_ARRAY( RegMask, argcnt );
229 uint i;
230 for( i = 0; i<argcnt; i++ ) {
231 sig_bt[i] = domain->field_at(i+TypeFunc::Parms)->basic_type();
232 }
233
234 // Pass array of ideal registers and length to USER code (from the AD file)
235 // that will convert this to an array of register numbers.
236 const StartNode *start = C->start();
237 start->calling_convention( sig_bt, vm_parm_regs, argcnt );
238 #ifdef ASSERT
239 // Sanity check users' calling convention. Real handy while trying to
240 // get the initial port correct.
241 { for (uint i = 0; i<argcnt; i++) {
242 if( !vm_parm_regs[i].first()->is_valid() && !vm_parm_regs[i].second()->is_valid() ) {
243 assert(domain->field_at(i+TypeFunc::Parms)==Type::HALF, "only allowed on halve" );
506 idealreg2mhdebugmask[Op_VecS] = &rms[31];
507 idealreg2mhdebugmask[Op_VecD] = &rms[32];
508 idealreg2mhdebugmask[Op_VecX] = &rms[33];
509 idealreg2mhdebugmask[Op_VecY] = &rms[34];
510 idealreg2mhdebugmask[Op_VecZ] = &rms[35];
511
512 idealreg2spillmask [Op_RegVectMask] = &rms[36];
513 idealreg2debugmask [Op_RegVectMask] = &rms[37];
514 idealreg2mhdebugmask[Op_RegVectMask] = &rms[38];
515
516 OptoReg::Name i;
517
518 // At first, start with the empty mask
519 C->FIRST_STACK_mask().Clear();
520
521 // Add in the incoming argument area
522 OptoReg::Name init_in = OptoReg::add(_old_SP, C->out_preserve_stack_slots());
523 for (i = init_in; i < _in_arg_limit; i = OptoReg::add(i,1)) {
524 C->FIRST_STACK_mask().Insert(i);
525 }
526 // Add in all bits past the outgoing argument area
527 guarantee(RegMask::can_represent_arg(OptoReg::add(_out_arg_limit,-1)),
528 "must be able to represent all call arguments in reg mask");
529 OptoReg::Name init = _out_arg_limit;
530 for (i = init; RegMask::can_represent(i); i = OptoReg::add(i,1)) {
531 C->FIRST_STACK_mask().Insert(i);
532 }
533 // Finally, set the "infinite stack" bit.
534 C->FIRST_STACK_mask().set_AllStack();
535
536 // Make spill masks. Registers for their class, plus FIRST_STACK_mask.
537 RegMask aligned_stack_mask = C->FIRST_STACK_mask();
538 // Keep spill masks aligned.
539 aligned_stack_mask.clear_to_pairs();
540 assert(aligned_stack_mask.is_AllStack(), "should be infinite stack");
541 RegMask scalable_stack_mask = aligned_stack_mask;
542
543 *idealreg2spillmask[Op_RegP] = *idealreg2regmask[Op_RegP];
544 #ifdef _LP64
545 *idealreg2spillmask[Op_RegN] = *idealreg2regmask[Op_RegN];
764 _register_save_policy[reg] == 'E' ||
765 _register_save_policy[reg] == 'A'; // Save-on-entry register?
766 }
767
768 //---------------------------Fixup_Save_On_Entry-------------------------------
769 void Matcher::Fixup_Save_On_Entry( ) {
770 init_first_stack_mask();
771
772 Node *root = C->root(); // Short name for root
773 // Count number of save-on-entry registers.
774 uint soe_cnt = number_of_saved_registers();
775 uint i;
776
777 // Find the procedure Start Node
778 StartNode *start = C->start();
779 assert( start, "Expect a start node" );
780
781 // Input RegMask array shared by all Returns.
782 // The type for doubles and longs has a count of 2, but
783 // there is only 1 returned value
784 uint ret_edge_cnt = TypeFunc::Parms + ((C->tf()->range()->cnt() == TypeFunc::Parms) ? 0 : 1);
785 RegMask *ret_rms = init_input_masks( ret_edge_cnt + soe_cnt, _return_addr_mask, c_frame_ptr_mask );
786 // Returns have 0 or 1 returned values depending on call signature.
787 // Return register is specified by return_value in the AD file.
788 if (ret_edge_cnt > TypeFunc::Parms)
789 ret_rms[TypeFunc::Parms+0] = _return_value_mask;
790
791 // Input RegMask array shared by all Rethrows.
792 uint reth_edge_cnt = TypeFunc::Parms+1;
793 RegMask *reth_rms = init_input_masks( reth_edge_cnt + soe_cnt, _return_addr_mask, c_frame_ptr_mask );
794 // Rethrow takes exception oop only, but in the argument 0 slot.
795 OptoReg::Name reg = find_receiver();
796 if (reg >= 0) {
797 reth_rms[TypeFunc::Parms] = mreg2regmask[reg];
798 #ifdef _LP64
799 // Need two slots for ptrs in 64-bit land
800 reth_rms[TypeFunc::Parms].Insert(OptoReg::add(OptoReg::Name(reg), 1));
801 #endif
802 }
803
804 // Input RegMask array shared by all TailCalls
805 uint tail_call_edge_cnt = TypeFunc::Parms+2;
806 RegMask *tail_call_rms = init_input_masks( tail_call_edge_cnt + soe_cnt, _return_addr_mask, c_frame_ptr_mask );
807
808 // Input RegMask array shared by all TailJumps
809 uint tail_jump_edge_cnt = TypeFunc::Parms+2;
836 }
837
838 // Input RegMask array shared by all Halts
839 uint halt_edge_cnt = TypeFunc::Parms;
840 RegMask *halt_rms = init_input_masks( halt_edge_cnt + soe_cnt, _return_addr_mask, c_frame_ptr_mask );
841
842 // Capture the return input masks into each exit flavor
843 for( i=1; i < root->req(); i++ ) {
844 MachReturnNode *exit = root->in(i)->as_MachReturn();
845 switch( exit->ideal_Opcode() ) {
846 case Op_Return : exit->_in_rms = ret_rms; break;
847 case Op_Rethrow : exit->_in_rms = reth_rms; break;
848 case Op_TailCall : exit->_in_rms = tail_call_rms; break;
849 case Op_TailJump : exit->_in_rms = tail_jump_rms; break;
850 case Op_Halt : exit->_in_rms = halt_rms; break;
851 default : ShouldNotReachHere();
852 }
853 }
854
855 // Next unused projection number from Start.
856 int proj_cnt = C->tf()->domain()->cnt();
857
858 // Do all the save-on-entry registers. Make projections from Start for
859 // them, and give them a use at the exit points. To the allocator, they
860 // look like incoming register arguments.
861 for( i = 0; i < _last_Mach_Reg; i++ ) {
862 if( is_save_on_entry(i) ) {
863
864 // Add the save-on-entry to the mask array
865 ret_rms [ ret_edge_cnt] = mreg2regmask[i];
866 reth_rms [ reth_edge_cnt] = mreg2regmask[i];
867 tail_call_rms[tail_call_edge_cnt] = mreg2regmask[i];
868 tail_jump_rms[tail_jump_edge_cnt] = mreg2regmask[i];
869 // Halts need the SOE registers, but only in the stack as debug info.
870 // A just-prior uncommon-trap or deoptimization will use the SOE regs.
871 halt_rms [ halt_edge_cnt] = *idealreg2spillmask[_register_save_type[i]];
872
873 Node *mproj;
874
875 // Is this a RegF low half of a RegD? Double up 2 adjacent RegF's
876 // into a single RegD.
1108 Node *oldn = n;
1109 // Old-space or new-space check
1110 if (!C->node_arena()->contains(n)) {
1111 // Old space!
1112 Node* m;
1113 if (has_new_node(n)) { // Not yet Label/Reduced
1114 m = new_node(n);
1115 } else {
1116 if (!is_dontcare(n)) { // Matcher can match this guy
1117 // Calls match special. They match alone with no children.
1118 // Their children, the incoming arguments, match normally.
1119 m = n->is_SafePoint() ? match_sfpt(n->as_SafePoint()):match_tree(n);
1120 if (C->failing()) return NULL;
1121 if (m == NULL) { Matcher::soft_match_failure(); return NULL; }
1122 if (n->is_MemBar()) {
1123 m->as_MachMemBar()->set_adr_type(n->adr_type());
1124 }
1125 } else { // Nothing the matcher cares about
1126 if (n->is_Proj() && n->in(0) != NULL && n->in(0)->is_Multi()) { // Projections?
1127 // Convert to machine-dependent projection
1128 m = n->in(0)->as_Multi()->match( n->as_Proj(), this );
1129 NOT_PRODUCT(record_new2old(m, n);)
1130 if (m->in(0) != NULL) // m might be top
1131 collect_null_checks(m, n);
1132 } else { // Else just a regular 'ol guy
1133 m = n->clone(); // So just clone into new-space
1134 NOT_PRODUCT(record_new2old(m, n);)
1135 // Def-Use edges will be added incrementally as Uses
1136 // of this node are matched.
1137 assert(m->outcnt() == 0, "no Uses of this clone yet");
1138 }
1139 }
1140
1141 set_new_node(n, m); // Map old to new
1142 if (_old_node_note_array != NULL) {
1143 Node_Notes* nn = C->locate_node_notes(_old_node_note_array,
1144 n->_idx);
1145 C->set_node_notes_at(m->_idx, nn);
1146 }
1147 debug_only(match_alias_type(C, n, m));
1148 }
1247 }
1248 return OptoReg::as_OptoReg(reg);
1249 }
1250
1251
1252 //------------------------------match_sfpt-------------------------------------
1253 // Helper function to match call instructions. Calls match special.
1254 // They match alone with no children. Their children, the incoming
1255 // arguments, match normally.
1256 MachNode *Matcher::match_sfpt( SafePointNode *sfpt ) {
1257 MachSafePointNode *msfpt = NULL;
1258 MachCallNode *mcall = NULL;
1259 uint cnt;
1260 // Split out case for SafePoint vs Call
1261 CallNode *call;
1262 const TypeTuple *domain;
1263 ciMethod* method = NULL;
1264 bool is_method_handle_invoke = false; // for special kill effects
1265 if( sfpt->is_Call() ) {
1266 call = sfpt->as_Call();
1267 domain = call->tf()->domain();
1268 cnt = domain->cnt();
1269
1270 // Match just the call, nothing else
1271 MachNode *m = match_tree(call);
1272 if (C->failing()) return NULL;
1273 if( m == NULL ) { Matcher::soft_match_failure(); return NULL; }
1274
1275 // Copy data from the Ideal SafePoint to the machine version
1276 mcall = m->as_MachCall();
1277
1278 mcall->set_tf( call->tf());
1279 mcall->set_entry_point( call->entry_point());
1280 mcall->set_cnt( call->cnt());
1281 mcall->set_guaranteed_safepoint(call->guaranteed_safepoint());
1282
1283 if( mcall->is_MachCallJava() ) {
1284 MachCallJavaNode *mcall_java = mcall->as_MachCallJava();
1285 const CallJavaNode *call_java = call->as_CallJava();
1286 assert(call_java->validate_symbolic_info(), "inconsistent info");
1287 method = call_java->method();
1335 for (uint i = 0; i < cnt; i++) ::new (&(msfpt->_in_rms[i])) RegMask();
1336
1337 // Do all the pre-defined non-Empty register masks
1338 msfpt->_in_rms[TypeFunc::ReturnAdr] = _return_addr_mask;
1339 msfpt->_in_rms[TypeFunc::FramePtr ] = c_frame_ptr_mask;
1340
1341 // Place first outgoing argument can possibly be put.
1342 OptoReg::Name begin_out_arg_area = OptoReg::add(_new_SP, C->out_preserve_stack_slots());
1343 assert( is_even(begin_out_arg_area), "" );
1344 // Compute max outgoing register number per call site.
1345 OptoReg::Name out_arg_limit_per_call = begin_out_arg_area;
1346 // Calls to C may hammer extra stack slots above and beyond any arguments.
1347 // These are usually backing store for register arguments for varargs.
1348 if( call != NULL && call->is_CallRuntime() )
1349 out_arg_limit_per_call = OptoReg::add(out_arg_limit_per_call,C->varargs_C_out_slots_killed());
1350 if( call != NULL && call->is_CallNative() )
1351 out_arg_limit_per_call = OptoReg::add(out_arg_limit_per_call, call->as_CallNative()->_shadow_space_bytes);
1352
1353
1354 // Do the normal argument list (parameters) register masks
1355 int argcnt = cnt - TypeFunc::Parms;
1356 if( argcnt > 0 ) { // Skip it all if we have no args
1357 BasicType *sig_bt = NEW_RESOURCE_ARRAY( BasicType, argcnt );
1358 VMRegPair *parm_regs = NEW_RESOURCE_ARRAY( VMRegPair, argcnt );
1359 int i;
1360 for( i = 0; i < argcnt; i++ ) {
1361 sig_bt[i] = domain->field_at(i+TypeFunc::Parms)->basic_type();
1362 }
1363 // V-call to pick proper calling convention
1364 call->calling_convention( sig_bt, parm_regs, argcnt );
1365
1366 #ifdef ASSERT
1367 // Sanity check users' calling convention. Really handy during
1368 // the initial porting effort. Fairly expensive otherwise.
1369 { for (int i = 0; i<argcnt; i++) {
1370 if( !parm_regs[i].first()->is_valid() &&
1371 !parm_regs[i].second()->is_valid() ) continue;
1372 VMReg reg1 = parm_regs[i].first();
1373 VMReg reg2 = parm_regs[i].second();
1374 for (int j = 0; j < i; j++) {
1375 if( !parm_regs[j].first()->is_valid() &&
1376 !parm_regs[j].second()->is_valid() ) continue;
1377 VMReg reg3 = parm_regs[j].first();
1378 VMReg reg4 = parm_regs[j].second();
1379 if( !reg1->is_valid() ) {
1380 assert( !reg2->is_valid(), "valid halvsies" );
1381 } else if( !reg3->is_valid() ) {
1382 assert( !reg4->is_valid(), "valid halvsies" );
1383 } else {
1384 assert( reg1 != reg2, "calling conv. must produce distinct regs");
1385 assert( reg1 != reg3, "calling conv. must produce distinct regs");
1386 assert( reg1 != reg4, "calling conv. must produce distinct regs");
1387 assert( reg2 != reg3, "calling conv. must produce distinct regs");
1388 assert( reg2 != reg4 || !reg2->is_valid(), "calling conv. must produce distinct regs");
1389 assert( reg3 != reg4, "calling conv. must produce distinct regs");
1390 }
1391 }
1392 }
1393 }
1394 #endif
1395
1396 // Visit each argument. Compute its outgoing register mask.
1397 // Return results now can have 2 bits returned.
1398 // Compute max over all outgoing arguments both per call-site
1399 // and over the entire method.
1400 for( i = 0; i < argcnt; i++ ) {
1401 // Address of incoming argument mask to fill in
1402 RegMask *rm = &mcall->_in_rms[i+TypeFunc::Parms];
1403 VMReg first = parm_regs[i].first();
1404 VMReg second = parm_regs[i].second();
1405 if(!first->is_valid() &&
1406 !second->is_valid()) {
1407 continue; // Avoid Halves
1408 }
1409 // Handle case where arguments are in vector registers.
1410 if(call->in(TypeFunc::Parms + i)->bottom_type()->isa_vect()) {
1411 OptoReg::Name reg_fst = OptoReg::as_OptoReg(first);
1412 OptoReg::Name reg_snd = OptoReg::as_OptoReg(second);
1413 assert (reg_fst <= reg_snd, "fst=%d snd=%d", reg_fst, reg_snd);
1414 for (OptoReg::Name r = reg_fst; r <= reg_snd; r++) {
1415 rm->Insert(r);
1416 }
1417 }
1418 // Grab first register, adjust stack slots and insert in mask.
1419 OptoReg::Name reg1 = warp_outgoing_stk_arg(first, begin_out_arg_area, out_arg_limit_per_call );
1420 if (OptoReg::is_valid(reg1))
1421 rm->Insert( reg1 );
1422 // Grab second register (if any), adjust stack slots and insert in mask.
1423 OptoReg::Name reg2 = warp_outgoing_stk_arg(second, begin_out_arg_area, out_arg_limit_per_call );
1424 if (OptoReg::is_valid(reg2))
1425 rm->Insert( reg2 );
1426 } // End of for all arguments
1427 }
1428
1429 // Compute the max stack slot killed by any call. These will not be
1430 // available for debug info, and will be used to adjust FIRST_STACK_mask
1431 // after all call sites have been visited.
1432 if( _out_arg_limit < out_arg_limit_per_call)
1433 _out_arg_limit = out_arg_limit_per_call;
1434
1435 if (mcall) {
1436 // Kill the outgoing argument area, including any non-argument holes and
1437 // any legacy C-killed slots. Use Fat-Projections to do the killing.
1438 // Since the max-per-method covers the max-per-call-site and debug info
1439 // is excluded on the max-per-method basis, debug info cannot land in
1440 // this killed area.
1441 uint r_cnt = mcall->tf()->range()->cnt();
1442 MachProjNode *proj = new MachProjNode( mcall, r_cnt+10000, RegMask::Empty, MachProjNode::fat_proj );
1443 if (!RegMask::can_represent_arg(OptoReg::Name(out_arg_limit_per_call-1))) {
1444 C->record_method_not_compilable("unsupported outgoing calling sequence");
1445 } else {
1446 for (int i = begin_out_arg_area; i < out_arg_limit_per_call; i++)
1447 proj->_rout.Insert(OptoReg::Name(i));
1448 }
1449 if (proj->_rout.is_NotEmpty()) {
1450 push_projection(proj);
1451 }
1452 }
1453 // Transfer the safepoint information from the call to the mcall
1454 // Move the JVMState list
1455 msfpt->set_jvms(sfpt->jvms());
1456 for (JVMState* jvms = msfpt->jvms(); jvms; jvms = jvms->caller()) {
1457 jvms->set_map(sfpt);
1458 }
1459
1460 // Debug inputs begin just after the last incoming parameter
1461 assert((mcall == NULL) || (mcall->jvms() == NULL) ||
1462 (mcall->jvms()->debug_start() + mcall->_jvmadj == mcall->tf()->domain()->cnt()), "");
1463
1464 // Add additional edges.
1465 if (msfpt->mach_constant_base_node_input() != (uint)-1 && !msfpt->is_MachCallLeaf()) {
1466 // For these calls we can not add MachConstantBase in expand(), as the
1467 // ins are not complete then.
1468 msfpt->ins_req(msfpt->mach_constant_base_node_input(), C->mach_constant_base_node());
1469 if (msfpt->jvms() &&
1470 msfpt->mach_constant_base_node_input() <= msfpt->jvms()->debug_start() + msfpt->_jvmadj) {
1471 // We added an edge before jvms, so we must adapt the position of the ins.
1472 msfpt->jvms()->adapt_position(+1);
1473 }
1474 }
1475
1476 // Registers killed by the call are set in the local scheduling pass
1477 // of Global Code Motion.
1478 return msfpt;
1479 }
1480
1481 //---------------------------match_tree----------------------------------------
1482 // Match a Ideal Node DAG - turn it into a tree; Label & Reduce. Used as part
2125 set_shared(n); // Flag as shared and
2126 if (n->is_DecodeNarrowPtr()) {
2127 // Oop field/array element loads must be shared but since
2128 // they are shared through a DecodeN they may appear to have
2129 // a single use so force sharing here.
2130 set_shared(n->in(1));
2131 }
2132 mstack.pop(); // remove node from stack
2133 continue;
2134 }
2135 nstate = Visit; // Not already visited; so visit now
2136 }
2137 if (nstate == Visit) {
2138 mstack.set_state(Post_Visit);
2139 set_visited(n); // Flag as visited now
2140 bool mem_op = false;
2141 int mem_addr_idx = MemNode::Address;
2142 if (find_shared_visit(mstack, n, nop, mem_op, mem_addr_idx)) {
2143 continue;
2144 }
2145 for (int i = n->req() - 1; i >= 0; --i) { // For my children
2146 Node* m = n->in(i); // Get ith input
2147 if (m == NULL) {
2148 continue; // Ignore NULLs
2149 }
2150 if (clone_node(n, m, mstack)) {
2151 continue;
2152 }
2153
2154 // Clone addressing expressions as they are "free" in memory access instructions
2155 if (mem_op && i == mem_addr_idx && m->is_AddP() &&
2156 // When there are other uses besides address expressions
2157 // put it on stack and mark as shared.
2158 !is_visited(m)) {
2159 // Some inputs for address expression are not put on stack
2160 // to avoid marking them as shared and forcing them into register
2161 // if they are used only in address expressions.
2162 // But they should be marked as shared if there are other uses
2163 // besides address expressions.
2164
2165 if (pd_clone_address_expressions(m->as_AddP(), mstack, address_visited)) {
2438 case Op_FmaD:
2439 case Op_FmaF:
2440 case Op_FmaVD:
2441 case Op_FmaVF: {
2442 // Restructure into a binary tree for Matching.
2443 Node* pair = new BinaryNode(n->in(1), n->in(2));
2444 n->set_req(2, pair);
2445 n->set_req(1, n->in(3));
2446 n->del_req(3);
2447 break;
2448 }
2449 case Op_MulAddS2I: {
2450 Node* pair1 = new BinaryNode(n->in(1), n->in(2));
2451 Node* pair2 = new BinaryNode(n->in(3), n->in(4));
2452 n->set_req(1, pair1);
2453 n->set_req(2, pair2);
2454 n->del_req(4);
2455 n->del_req(3);
2456 break;
2457 }
2458 case Op_CopySignD:
2459 case Op_SignumF:
2460 case Op_SignumD: {
2461 Node* pair = new BinaryNode(n->in(2), n->in(3));
2462 n->set_req(2, pair);
2463 n->del_req(3);
2464 break;
2465 }
2466 case Op_VectorBlend:
2467 case Op_VectorInsert: {
2468 Node* pair = new BinaryNode(n->in(1), n->in(2));
2469 n->set_req(1, pair);
2470 n->set_req(2, n->in(3));
2471 n->del_req(3);
2472 break;
2473 }
2474 case Op_LoadVectorGatherMasked:
2475 case Op_StoreVectorScatter: {
2476 Node* pair = new BinaryNode(n->in(MemNode::ValueIn), n->in(MemNode::ValueIn+1));
2477 n->set_req(MemNode::ValueIn, pair);
|
166 Unique_Node_List worklist;
167 VectorSet visited;
168 worklist.push(xroot);
169 while (worklist.size() > 0) {
170 Node* n = worklist.pop();
171 visited.set(n->_idx);
172 assert(C->node_arena()->contains(n), "dead node");
173 for (uint j = 0; j < n->req(); j++) {
174 Node* in = n->in(j);
175 if (in != NULL) {
176 assert(C->node_arena()->contains(in), "dead node");
177 if (!visited.test(in->_idx)) {
178 worklist.push(in);
179 }
180 }
181 }
182 }
183 }
184 #endif
185
186 // Array of RegMask, one per returned values (inline type instances can
187 // be returned as multiple return values, one per field)
188 RegMask* Matcher::return_values_mask(const TypeFunc* tf) {
189 const TypeTuple* range = tf->range_cc();
190 uint cnt = range->cnt() - TypeFunc::Parms;
191 if (cnt == 0) {
192 return NULL;
193 }
194 RegMask* mask = NEW_RESOURCE_ARRAY(RegMask, cnt);
195 BasicType* sig_bt = NEW_RESOURCE_ARRAY(BasicType, cnt);
196 VMRegPair* vm_parm_regs = NEW_RESOURCE_ARRAY(VMRegPair, cnt);
197 for (uint i = 0; i < cnt; i++) {
198 sig_bt[i] = range->field_at(i+TypeFunc::Parms)->basic_type();
199 }
200
201 int regs = SharedRuntime::java_return_convention(sig_bt, vm_parm_regs, cnt);
202 if (regs <= 0) {
203 // We ran out of registers to store the IsInit information for a nullable inline type return.
204 // Since it is only set in the 'call_epilog', we can simply put it on the stack.
205 assert(tf->returns_inline_type_as_fields(), "should have been tested during graph construction");
206 // TODO 8284443 Can we teach the register allocator to reserve a stack slot instead?
207 // mask[--cnt] = STACK_ONLY_mask does not work (test with -XX:+StressGCM)
208 int slot = C->fixed_slots() - 2;
209 if (C->needs_stack_repair()) {
210 slot -= 2; // Account for stack increment value
211 }
212 mask[--cnt].Clear();
213 mask[cnt].Insert(OptoReg::stack2reg(slot));
214 }
215 for (uint i = 0; i < cnt; i++) {
216 mask[i].Clear();
217
218 OptoReg::Name reg1 = OptoReg::as_OptoReg(vm_parm_regs[i].first());
219 if (OptoReg::is_valid(reg1)) {
220 mask[i].Insert(reg1);
221 }
222 OptoReg::Name reg2 = OptoReg::as_OptoReg(vm_parm_regs[i].second());
223 if (OptoReg::is_valid(reg2)) {
224 mask[i].Insert(reg2);
225 }
226 }
227
228 return mask;
229 }
230
231 //---------------------------match---------------------------------------------
232 void Matcher::match( ) {
233 if( MaxLabelRootDepth < 100 ) { // Too small?
234 assert(false, "invalid MaxLabelRootDepth, increase it to 100 minimum");
235 MaxLabelRootDepth = 100;
236 }
237 // One-time initialization of some register masks.
238 init_spill_mask( C->root()->in(1) );
239 _return_addr_mask = return_addr();
240 #ifdef _LP64
241 // Pointers take 2 slots in 64-bit land
242 _return_addr_mask.Insert(OptoReg::add(return_addr(),1));
243 #endif
244
245 // Map Java-signature return types into return register-value
246 // machine registers.
247 _return_values_mask = return_values_mask(C->tf());
248
249 // ---------------
250 // Frame Layout
251
252 // Need the method signature to determine the incoming argument types,
253 // because the types determine which registers the incoming arguments are
254 // in, and this affects the matched code.
255 const TypeTuple *domain = C->tf()->domain_cc();
256 uint argcnt = domain->cnt() - TypeFunc::Parms;
257 BasicType *sig_bt = NEW_RESOURCE_ARRAY( BasicType, argcnt );
258 VMRegPair *vm_parm_regs = NEW_RESOURCE_ARRAY( VMRegPair, argcnt );
259 _parm_regs = NEW_RESOURCE_ARRAY( OptoRegPair, argcnt );
260 _calling_convention_mask = NEW_RESOURCE_ARRAY( RegMask, argcnt );
261 uint i;
262 for( i = 0; i<argcnt; i++ ) {
263 sig_bt[i] = domain->field_at(i+TypeFunc::Parms)->basic_type();
264 }
265
266 // Pass array of ideal registers and length to USER code (from the AD file)
267 // that will convert this to an array of register numbers.
268 const StartNode *start = C->start();
269 start->calling_convention( sig_bt, vm_parm_regs, argcnt );
270 #ifdef ASSERT
271 // Sanity check users' calling convention. Real handy while trying to
272 // get the initial port correct.
273 { for (uint i = 0; i<argcnt; i++) {
274 if( !vm_parm_regs[i].first()->is_valid() && !vm_parm_regs[i].second()->is_valid() ) {
275 assert(domain->field_at(i+TypeFunc::Parms)==Type::HALF, "only allowed on halve" );
538 idealreg2mhdebugmask[Op_VecS] = &rms[31];
539 idealreg2mhdebugmask[Op_VecD] = &rms[32];
540 idealreg2mhdebugmask[Op_VecX] = &rms[33];
541 idealreg2mhdebugmask[Op_VecY] = &rms[34];
542 idealreg2mhdebugmask[Op_VecZ] = &rms[35];
543
544 idealreg2spillmask [Op_RegVectMask] = &rms[36];
545 idealreg2debugmask [Op_RegVectMask] = &rms[37];
546 idealreg2mhdebugmask[Op_RegVectMask] = &rms[38];
547
548 OptoReg::Name i;
549
550 // At first, start with the empty mask
551 C->FIRST_STACK_mask().Clear();
552
553 // Add in the incoming argument area
554 OptoReg::Name init_in = OptoReg::add(_old_SP, C->out_preserve_stack_slots());
555 for (i = init_in; i < _in_arg_limit; i = OptoReg::add(i,1)) {
556 C->FIRST_STACK_mask().Insert(i);
557 }
558
559 // Add in all bits past the outgoing argument area
560 guarantee(RegMask::can_represent_arg(OptoReg::add(_out_arg_limit,-1)),
561 "must be able to represent all call arguments in reg mask");
562 OptoReg::Name init = _out_arg_limit;
563 for (i = init; RegMask::can_represent(i); i = OptoReg::add(i,1)) {
564 C->FIRST_STACK_mask().Insert(i);
565 }
566 // Finally, set the "infinite stack" bit.
567 C->FIRST_STACK_mask().set_AllStack();
568
569 // Make spill masks. Registers for their class, plus FIRST_STACK_mask.
570 RegMask aligned_stack_mask = C->FIRST_STACK_mask();
571 // Keep spill masks aligned.
572 aligned_stack_mask.clear_to_pairs();
573 assert(aligned_stack_mask.is_AllStack(), "should be infinite stack");
574 RegMask scalable_stack_mask = aligned_stack_mask;
575
576 *idealreg2spillmask[Op_RegP] = *idealreg2regmask[Op_RegP];
577 #ifdef _LP64
578 *idealreg2spillmask[Op_RegN] = *idealreg2regmask[Op_RegN];
797 _register_save_policy[reg] == 'E' ||
798 _register_save_policy[reg] == 'A'; // Save-on-entry register?
799 }
800
801 //---------------------------Fixup_Save_On_Entry-------------------------------
802 void Matcher::Fixup_Save_On_Entry( ) {
803 init_first_stack_mask();
804
805 Node *root = C->root(); // Short name for root
806 // Count number of save-on-entry registers.
807 uint soe_cnt = number_of_saved_registers();
808 uint i;
809
810 // Find the procedure Start Node
811 StartNode *start = C->start();
812 assert( start, "Expect a start node" );
813
814 // Input RegMask array shared by all Returns.
815 // The type for doubles and longs has a count of 2, but
816 // there is only 1 returned value
817 uint ret_edge_cnt = C->tf()->range_cc()->cnt();
818 RegMask *ret_rms = init_input_masks( ret_edge_cnt + soe_cnt, _return_addr_mask, c_frame_ptr_mask );
819 for (i = TypeFunc::Parms; i < ret_edge_cnt; i++) {
820 ret_rms[i] = _return_values_mask[i-TypeFunc::Parms];
821 }
822
823 // Input RegMask array shared by all Rethrows.
824 uint reth_edge_cnt = TypeFunc::Parms+1;
825 RegMask *reth_rms = init_input_masks( reth_edge_cnt + soe_cnt, _return_addr_mask, c_frame_ptr_mask );
826 // Rethrow takes exception oop only, but in the argument 0 slot.
827 OptoReg::Name reg = find_receiver();
828 if (reg >= 0) {
829 reth_rms[TypeFunc::Parms] = mreg2regmask[reg];
830 #ifdef _LP64
831 // Need two slots for ptrs in 64-bit land
832 reth_rms[TypeFunc::Parms].Insert(OptoReg::add(OptoReg::Name(reg), 1));
833 #endif
834 }
835
836 // Input RegMask array shared by all TailCalls
837 uint tail_call_edge_cnt = TypeFunc::Parms+2;
838 RegMask *tail_call_rms = init_input_masks( tail_call_edge_cnt + soe_cnt, _return_addr_mask, c_frame_ptr_mask );
839
840 // Input RegMask array shared by all TailJumps
841 uint tail_jump_edge_cnt = TypeFunc::Parms+2;
868 }
869
870 // Input RegMask array shared by all Halts
871 uint halt_edge_cnt = TypeFunc::Parms;
872 RegMask *halt_rms = init_input_masks( halt_edge_cnt + soe_cnt, _return_addr_mask, c_frame_ptr_mask );
873
874 // Capture the return input masks into each exit flavor
875 for( i=1; i < root->req(); i++ ) {
876 MachReturnNode *exit = root->in(i)->as_MachReturn();
877 switch( exit->ideal_Opcode() ) {
878 case Op_Return : exit->_in_rms = ret_rms; break;
879 case Op_Rethrow : exit->_in_rms = reth_rms; break;
880 case Op_TailCall : exit->_in_rms = tail_call_rms; break;
881 case Op_TailJump : exit->_in_rms = tail_jump_rms; break;
882 case Op_Halt : exit->_in_rms = halt_rms; break;
883 default : ShouldNotReachHere();
884 }
885 }
886
887 // Next unused projection number from Start.
888 int proj_cnt = C->tf()->domain_cc()->cnt();
889
890 // Do all the save-on-entry registers. Make projections from Start for
891 // them, and give them a use at the exit points. To the allocator, they
892 // look like incoming register arguments.
893 for( i = 0; i < _last_Mach_Reg; i++ ) {
894 if( is_save_on_entry(i) ) {
895
896 // Add the save-on-entry to the mask array
897 ret_rms [ ret_edge_cnt] = mreg2regmask[i];
898 reth_rms [ reth_edge_cnt] = mreg2regmask[i];
899 tail_call_rms[tail_call_edge_cnt] = mreg2regmask[i];
900 tail_jump_rms[tail_jump_edge_cnt] = mreg2regmask[i];
901 // Halts need the SOE registers, but only in the stack as debug info.
902 // A just-prior uncommon-trap or deoptimization will use the SOE regs.
903 halt_rms [ halt_edge_cnt] = *idealreg2spillmask[_register_save_type[i]];
904
905 Node *mproj;
906
907 // Is this a RegF low half of a RegD? Double up 2 adjacent RegF's
908 // into a single RegD.
1140 Node *oldn = n;
1141 // Old-space or new-space check
1142 if (!C->node_arena()->contains(n)) {
1143 // Old space!
1144 Node* m;
1145 if (has_new_node(n)) { // Not yet Label/Reduced
1146 m = new_node(n);
1147 } else {
1148 if (!is_dontcare(n)) { // Matcher can match this guy
1149 // Calls match special. They match alone with no children.
1150 // Their children, the incoming arguments, match normally.
1151 m = n->is_SafePoint() ? match_sfpt(n->as_SafePoint()):match_tree(n);
1152 if (C->failing()) return NULL;
1153 if (m == NULL) { Matcher::soft_match_failure(); return NULL; }
1154 if (n->is_MemBar()) {
1155 m->as_MachMemBar()->set_adr_type(n->adr_type());
1156 }
1157 } else { // Nothing the matcher cares about
1158 if (n->is_Proj() && n->in(0) != NULL && n->in(0)->is_Multi()) { // Projections?
1159 // Convert to machine-dependent projection
1160 RegMask* mask = NULL;
1161 if (n->in(0)->is_Call() && n->in(0)->as_Call()->tf()->returns_inline_type_as_fields()) {
1162 mask = return_values_mask(n->in(0)->as_Call()->tf());
1163 }
1164 m = n->in(0)->as_Multi()->match(n->as_Proj(), this, mask);
1165 NOT_PRODUCT(record_new2old(m, n);)
1166 if (m->in(0) != NULL) // m might be top
1167 collect_null_checks(m, n);
1168 } else { // Else just a regular 'ol guy
1169 m = n->clone(); // So just clone into new-space
1170 NOT_PRODUCT(record_new2old(m, n);)
1171 // Def-Use edges will be added incrementally as Uses
1172 // of this node are matched.
1173 assert(m->outcnt() == 0, "no Uses of this clone yet");
1174 }
1175 }
1176
1177 set_new_node(n, m); // Map old to new
1178 if (_old_node_note_array != NULL) {
1179 Node_Notes* nn = C->locate_node_notes(_old_node_note_array,
1180 n->_idx);
1181 C->set_node_notes_at(m->_idx, nn);
1182 }
1183 debug_only(match_alias_type(C, n, m));
1184 }
1283 }
1284 return OptoReg::as_OptoReg(reg);
1285 }
1286
1287
1288 //------------------------------match_sfpt-------------------------------------
1289 // Helper function to match call instructions. Calls match special.
1290 // They match alone with no children. Their children, the incoming
1291 // arguments, match normally.
1292 MachNode *Matcher::match_sfpt( SafePointNode *sfpt ) {
1293 MachSafePointNode *msfpt = NULL;
1294 MachCallNode *mcall = NULL;
1295 uint cnt;
1296 // Split out case for SafePoint vs Call
1297 CallNode *call;
1298 const TypeTuple *domain;
1299 ciMethod* method = NULL;
1300 bool is_method_handle_invoke = false; // for special kill effects
1301 if( sfpt->is_Call() ) {
1302 call = sfpt->as_Call();
1303 domain = call->tf()->domain_cc();
1304 cnt = domain->cnt();
1305
1306 // Match just the call, nothing else
1307 MachNode *m = match_tree(call);
1308 if (C->failing()) return NULL;
1309 if( m == NULL ) { Matcher::soft_match_failure(); return NULL; }
1310
1311 // Copy data from the Ideal SafePoint to the machine version
1312 mcall = m->as_MachCall();
1313
1314 mcall->set_tf( call->tf());
1315 mcall->set_entry_point( call->entry_point());
1316 mcall->set_cnt( call->cnt());
1317 mcall->set_guaranteed_safepoint(call->guaranteed_safepoint());
1318
1319 if( mcall->is_MachCallJava() ) {
1320 MachCallJavaNode *mcall_java = mcall->as_MachCallJava();
1321 const CallJavaNode *call_java = call->as_CallJava();
1322 assert(call_java->validate_symbolic_info(), "inconsistent info");
1323 method = call_java->method();
1371 for (uint i = 0; i < cnt; i++) ::new (&(msfpt->_in_rms[i])) RegMask();
1372
1373 // Do all the pre-defined non-Empty register masks
1374 msfpt->_in_rms[TypeFunc::ReturnAdr] = _return_addr_mask;
1375 msfpt->_in_rms[TypeFunc::FramePtr ] = c_frame_ptr_mask;
1376
1377 // Place first outgoing argument can possibly be put.
1378 OptoReg::Name begin_out_arg_area = OptoReg::add(_new_SP, C->out_preserve_stack_slots());
1379 assert( is_even(begin_out_arg_area), "" );
1380 // Compute max outgoing register number per call site.
1381 OptoReg::Name out_arg_limit_per_call = begin_out_arg_area;
1382 // Calls to C may hammer extra stack slots above and beyond any arguments.
1383 // These are usually backing store for register arguments for varargs.
1384 if( call != NULL && call->is_CallRuntime() )
1385 out_arg_limit_per_call = OptoReg::add(out_arg_limit_per_call,C->varargs_C_out_slots_killed());
1386 if( call != NULL && call->is_CallNative() )
1387 out_arg_limit_per_call = OptoReg::add(out_arg_limit_per_call, call->as_CallNative()->_shadow_space_bytes);
1388
1389
1390 // Do the normal argument list (parameters) register masks
1391 // Null entry point is a special cast where the target of the call
1392 // is in a register.
1393 int adj = (call != NULL && call->entry_point() == NULL) ? 1 : 0;
1394 int argcnt = cnt - TypeFunc::Parms - adj;
1395 if( argcnt > 0 ) { // Skip it all if we have no args
1396 BasicType *sig_bt = NEW_RESOURCE_ARRAY( BasicType, argcnt );
1397 VMRegPair *parm_regs = NEW_RESOURCE_ARRAY( VMRegPair, argcnt );
1398 int i;
1399 for( i = 0; i < argcnt; i++ ) {
1400 sig_bt[i] = domain->field_at(i+TypeFunc::Parms+adj)->basic_type();
1401 }
1402 // V-call to pick proper calling convention
1403 call->calling_convention( sig_bt, parm_regs, argcnt );
1404
1405 #ifdef ASSERT
1406 // Sanity check users' calling convention. Really handy during
1407 // the initial porting effort. Fairly expensive otherwise.
1408 { for (int i = 0; i<argcnt; i++) {
1409 if( !parm_regs[i].first()->is_valid() &&
1410 !parm_regs[i].second()->is_valid() ) continue;
1411 VMReg reg1 = parm_regs[i].first();
1412 VMReg reg2 = parm_regs[i].second();
1413 for (int j = 0; j < i; j++) {
1414 if( !parm_regs[j].first()->is_valid() &&
1415 !parm_regs[j].second()->is_valid() ) continue;
1416 VMReg reg3 = parm_regs[j].first();
1417 VMReg reg4 = parm_regs[j].second();
1418 if( !reg1->is_valid() ) {
1419 assert( !reg2->is_valid(), "valid halvsies" );
1420 } else if( !reg3->is_valid() ) {
1421 assert( !reg4->is_valid(), "valid halvsies" );
1422 } else {
1423 assert( reg1 != reg2, "calling conv. must produce distinct regs");
1424 assert( reg1 != reg3, "calling conv. must produce distinct regs");
1425 assert( reg1 != reg4, "calling conv. must produce distinct regs");
1426 assert( reg2 != reg3, "calling conv. must produce distinct regs");
1427 assert( reg2 != reg4 || !reg2->is_valid(), "calling conv. must produce distinct regs");
1428 assert( reg3 != reg4, "calling conv. must produce distinct regs");
1429 }
1430 }
1431 }
1432 }
1433 #endif
1434
1435 // Visit each argument. Compute its outgoing register mask.
1436 // Return results now can have 2 bits returned.
1437 // Compute max over all outgoing arguments both per call-site
1438 // and over the entire method.
1439 for( i = 0; i < argcnt; i++ ) {
1440 // Address of incoming argument mask to fill in
1441 RegMask *rm = &mcall->_in_rms[i+TypeFunc::Parms+adj];
1442 VMReg first = parm_regs[i].first();
1443 VMReg second = parm_regs[i].second();
1444 if(!first->is_valid() &&
1445 !second->is_valid()) {
1446 continue; // Avoid Halves
1447 }
1448 // Handle case where arguments are in vector registers.
1449 if(call->in(TypeFunc::Parms + i)->bottom_type()->isa_vect()) {
1450 OptoReg::Name reg_fst = OptoReg::as_OptoReg(first);
1451 OptoReg::Name reg_snd = OptoReg::as_OptoReg(second);
1452 assert (reg_fst <= reg_snd, "fst=%d snd=%d", reg_fst, reg_snd);
1453 for (OptoReg::Name r = reg_fst; r <= reg_snd; r++) {
1454 rm->Insert(r);
1455 }
1456 }
1457 // Grab first register, adjust stack slots and insert in mask.
1458 OptoReg::Name reg1 = warp_outgoing_stk_arg(first, begin_out_arg_area, out_arg_limit_per_call );
1459 if (OptoReg::is_valid(reg1)) {
1460 rm->Insert( reg1 );
1461 }
1462 // Grab second register (if any), adjust stack slots and insert in mask.
1463 OptoReg::Name reg2 = warp_outgoing_stk_arg(second, begin_out_arg_area, out_arg_limit_per_call );
1464 if (OptoReg::is_valid(reg2)) {
1465 rm->Insert( reg2 );
1466 }
1467 } // End of for all arguments
1468 }
1469
1470 // Compute the max stack slot killed by any call. These will not be
1471 // available for debug info, and will be used to adjust FIRST_STACK_mask
1472 // after all call sites have been visited.
1473 if( _out_arg_limit < out_arg_limit_per_call)
1474 _out_arg_limit = out_arg_limit_per_call;
1475
1476 if (mcall) {
1477 // Kill the outgoing argument area, including any non-argument holes and
1478 // any legacy C-killed slots. Use Fat-Projections to do the killing.
1479 // Since the max-per-method covers the max-per-call-site and debug info
1480 // is excluded on the max-per-method basis, debug info cannot land in
1481 // this killed area.
1482 uint r_cnt = mcall->tf()->range_sig()->cnt();
1483 MachProjNode *proj = new MachProjNode( mcall, r_cnt+10000, RegMask::Empty, MachProjNode::fat_proj );
1484 if (!RegMask::can_represent_arg(OptoReg::Name(out_arg_limit_per_call-1))) {
1485 C->record_method_not_compilable("unsupported outgoing calling sequence");
1486 } else {
1487 for (int i = begin_out_arg_area; i < out_arg_limit_per_call; i++)
1488 proj->_rout.Insert(OptoReg::Name(i));
1489 }
1490 if (proj->_rout.is_NotEmpty()) {
1491 push_projection(proj);
1492 }
1493 }
1494 // Transfer the safepoint information from the call to the mcall
1495 // Move the JVMState list
1496 msfpt->set_jvms(sfpt->jvms());
1497 for (JVMState* jvms = msfpt->jvms(); jvms; jvms = jvms->caller()) {
1498 jvms->set_map(sfpt);
1499 }
1500
1501 // Debug inputs begin just after the last incoming parameter
1502 assert((mcall == NULL) || (mcall->jvms() == NULL) ||
1503 (mcall->jvms()->debug_start() + mcall->_jvmadj == mcall->tf()->domain_cc()->cnt()), "");
1504
1505 // Add additional edges.
1506 if (msfpt->mach_constant_base_node_input() != (uint)-1 && !msfpt->is_MachCallLeaf()) {
1507 // For these calls we can not add MachConstantBase in expand(), as the
1508 // ins are not complete then.
1509 msfpt->ins_req(msfpt->mach_constant_base_node_input(), C->mach_constant_base_node());
1510 if (msfpt->jvms() &&
1511 msfpt->mach_constant_base_node_input() <= msfpt->jvms()->debug_start() + msfpt->_jvmadj) {
1512 // We added an edge before jvms, so we must adapt the position of the ins.
1513 msfpt->jvms()->adapt_position(+1);
1514 }
1515 }
1516
1517 // Registers killed by the call are set in the local scheduling pass
1518 // of Global Code Motion.
1519 return msfpt;
1520 }
1521
1522 //---------------------------match_tree----------------------------------------
1523 // Match a Ideal Node DAG - turn it into a tree; Label & Reduce. Used as part
2166 set_shared(n); // Flag as shared and
2167 if (n->is_DecodeNarrowPtr()) {
2168 // Oop field/array element loads must be shared but since
2169 // they are shared through a DecodeN they may appear to have
2170 // a single use so force sharing here.
2171 set_shared(n->in(1));
2172 }
2173 mstack.pop(); // remove node from stack
2174 continue;
2175 }
2176 nstate = Visit; // Not already visited; so visit now
2177 }
2178 if (nstate == Visit) {
2179 mstack.set_state(Post_Visit);
2180 set_visited(n); // Flag as visited now
2181 bool mem_op = false;
2182 int mem_addr_idx = MemNode::Address;
2183 if (find_shared_visit(mstack, n, nop, mem_op, mem_addr_idx)) {
2184 continue;
2185 }
2186 for (int i = n->len() - 1; i >= 0; --i) { // For my children
2187 Node* m = n->in(i); // Get ith input
2188 if (m == NULL) {
2189 continue; // Ignore NULLs
2190 }
2191 if (clone_node(n, m, mstack)) {
2192 continue;
2193 }
2194
2195 // Clone addressing expressions as they are "free" in memory access instructions
2196 if (mem_op && i == mem_addr_idx && m->is_AddP() &&
2197 // When there are other uses besides address expressions
2198 // put it on stack and mark as shared.
2199 !is_visited(m)) {
2200 // Some inputs for address expression are not put on stack
2201 // to avoid marking them as shared and forcing them into register
2202 // if they are used only in address expressions.
2203 // But they should be marked as shared if there are other uses
2204 // besides address expressions.
2205
2206 if (pd_clone_address_expressions(m->as_AddP(), mstack, address_visited)) {
2479 case Op_FmaD:
2480 case Op_FmaF:
2481 case Op_FmaVD:
2482 case Op_FmaVF: {
2483 // Restructure into a binary tree for Matching.
2484 Node* pair = new BinaryNode(n->in(1), n->in(2));
2485 n->set_req(2, pair);
2486 n->set_req(1, n->in(3));
2487 n->del_req(3);
2488 break;
2489 }
2490 case Op_MulAddS2I: {
2491 Node* pair1 = new BinaryNode(n->in(1), n->in(2));
2492 Node* pair2 = new BinaryNode(n->in(3), n->in(4));
2493 n->set_req(1, pair1);
2494 n->set_req(2, pair2);
2495 n->del_req(4);
2496 n->del_req(3);
2497 break;
2498 }
2499 case Op_ClearArray: {
2500 Node* pair = new BinaryNode(n->in(2), n->in(3));
2501 n->set_req(2, pair);
2502 n->set_req(3, n->in(4));
2503 n->del_req(4);
2504 break;
2505 }
2506 case Op_CopySignD:
2507 case Op_SignumF:
2508 case Op_SignumD: {
2509 Node* pair = new BinaryNode(n->in(2), n->in(3));
2510 n->set_req(2, pair);
2511 n->del_req(3);
2512 break;
2513 }
2514 case Op_VectorBlend:
2515 case Op_VectorInsert: {
2516 Node* pair = new BinaryNode(n->in(1), n->in(2));
2517 n->set_req(1, pair);
2518 n->set_req(2, n->in(3));
2519 n->del_req(3);
2520 break;
2521 }
2522 case Op_LoadVectorGatherMasked:
2523 case Op_StoreVectorScatter: {
2524 Node* pair = new BinaryNode(n->in(MemNode::ValueIn), n->in(MemNode::ValueIn+1));
2525 n->set_req(MemNode::ValueIn, pair);
|