1332 x = new (phase->C, 3) SubFNode(sub->in(1), phase->transform(x)); 1333 } 1334 } else { 1335 if( sub->Opcode() != Op_SubD || 1336 sub->in(2) != x || 1337 phase->type(sub->in(1)) != tzero ) return NULL; 1338 x = new (phase->C, 2) AbsDNode(x); 1339 if (flip) { 1340 x = new (phase->C, 3) SubDNode(sub->in(1), phase->transform(x)); 1341 } 1342 } 1343 1344 return x; 1345 } 1346 1347 //------------------------------split_once------------------------------------- 1348 // Helper for split_flow_path 1349 static void split_once(PhaseIterGVN *igvn, Node *phi, Node *val, Node *n, Node *newn) { 1350 igvn->hash_delete(n); // Remove from hash before hacking edges 1351 1352 Node* predicate_proj = NULL; 1353 uint j = 1; 1354 for (uint i = phi->req()-1; i > 0; i--) { 1355 if (phi->in(i) == val) { // Found a path with val? 1356 if (n->is_Region()) { 1357 Node* proj = PhaseIdealLoop::find_predicate(n->in(i)); 1358 if (proj != NULL) { 1359 assert(predicate_proj == NULL, "only one predicate entry expected"); 1360 predicate_proj = proj; 1361 } 1362 } 1363 // Add to NEW Region/Phi, no DU info 1364 newn->set_req( j++, n->in(i) ); 1365 // Remove from OLD Region/Phi 1366 n->del_req(i); 1367 } 1368 } 1369 1370 // Register the new node but do not transform it. Cannot transform until the 1371 // entire Region/Phi conglomerate has been hacked as a single huge transform. 1372 igvn->register_new_node_with_optimizer( newn ); 1373 1374 // Clone loop predicates 1375 if (predicate_proj != NULL) { 1376 newn = igvn->clone_loop_predicates(predicate_proj, newn, !n->is_CountedLoop()); 1377 } 1378 1379 // Now I can point to the new node. 1380 n->add_req(newn); 1381 igvn->_worklist.push(n); 1382 } 1383 1384 //------------------------------split_flow_path-------------------------------- 1385 // Check for merging identical values and split flow paths 1386 static Node* split_flow_path(PhaseGVN *phase, PhiNode *phi) { 1387 BasicType bt = phi->type()->basic_type(); 1388 if( bt == T_ILLEGAL || type2size[bt] <= 0 ) 1389 return NULL; // Bail out on funny non-value stuff 1390 if( phi->req() <= 3 ) // Need at least 2 matched inputs and a 1391 return NULL; // third unequal input to be worth doing 1392 1393 // Scan for a constant 1394 uint i; 1395 for( i = 1; i < phi->req()-1; i++ ) { 1396 Node *n = phi->in(i); 1397 if( !n ) return NULL; 1398 if( phase->type(n) == Type::TOP ) return NULL; 1399 if( n->Opcode() == Op_ConP || n->Opcode() == Op_ConN ) 1400 break; 1401 } 1402 if( i >= phi->req() ) // Only split for constants 1403 return NULL; 1404 1405 Node *val = phi->in(i); // Constant to split for 1406 uint hit = 0; // Number of times it occurs 1407 1408 for( ; i < phi->req(); i++ ){ // Count occurrences of constant 1409 Node *n = phi->in(i); 1410 if( !n ) return NULL; 1411 if( phase->type(n) == Type::TOP ) return NULL; 1412 if( phi->in(i) == val ) 1413 hit++; 1414 } 1415 1416 if( hit <= 1 || // Make sure we find 2 or more 1417 hit == phi->req()-1 ) // and not ALL the same value 1418 return NULL; 1419 1420 // Now start splitting out the flow paths that merge the same value. 1421 // Split first the RegionNode. 1422 PhaseIterGVN *igvn = phase->is_IterGVN(); 1423 Node *r = phi->region(); 1424 RegionNode *newr = new (phase->C, hit+1) RegionNode(hit+1); 1425 split_once(igvn, phi, val, r, newr); 1426 1427 // Now split all other Phis than this one 1428 for (DUIterator_Fast kmax, k = r->fast_outs(kmax); k < kmax; k++) { 1429 Node* phi2 = r->fast_out(k); 1430 if( phi2->is_Phi() && phi2->as_Phi() != phi ) { 1431 PhiNode *newphi = PhiNode::make_blank(newr, phi2); 1432 split_once(igvn, phi, val, phi2, newphi); 1433 } 1434 } 1435 1436 // Clean up this guy 1437 igvn->hash_delete(phi); 1438 for( i = phi->req()-1; i > 0; i-- ) { 1439 if( phi->in(i) == val ) { 1440 phi->del_req(i); 1441 } 1442 } 1443 phi->add_req(val); | 1332 x = new (phase->C, 3) SubFNode(sub->in(1), phase->transform(x)); 1333 } 1334 } else { 1335 if( sub->Opcode() != Op_SubD || 1336 sub->in(2) != x || 1337 phase->type(sub->in(1)) != tzero ) return NULL; 1338 x = new (phase->C, 2) AbsDNode(x); 1339 if (flip) { 1340 x = new (phase->C, 3) SubDNode(sub->in(1), phase->transform(x)); 1341 } 1342 } 1343 1344 return x; 1345 } 1346 1347 //------------------------------split_once------------------------------------- 1348 // Helper for split_flow_path 1349 static void split_once(PhaseIterGVN *igvn, Node *phi, Node *val, Node *n, Node *newn) { 1350 igvn->hash_delete(n); // Remove from hash before hacking edges 1351 1352 uint j = 1; 1353 for (uint i = phi->req()-1; i > 0; i--) { 1354 if (phi->in(i) == val) { // Found a path with val? 1355 // Add to NEW Region/Phi, no DU info 1356 newn->set_req( j++, n->in(i) ); 1357 // Remove from OLD Region/Phi 1358 n->del_req(i); 1359 } 1360 } 1361 1362 // Register the new node but do not transform it. Cannot transform until the 1363 // entire Region/Phi conglomerate has been hacked as a single huge transform. 1364 igvn->register_new_node_with_optimizer( newn ); 1365 1366 // Now I can point to the new node. 1367 n->add_req(newn); 1368 igvn->_worklist.push(n); 1369 } 1370 1371 //------------------------------split_flow_path-------------------------------- 1372 // Check for merging identical values and split flow paths 1373 static Node* split_flow_path(PhaseGVN *phase, PhiNode *phi) { 1374 BasicType bt = phi->type()->basic_type(); 1375 if( bt == T_ILLEGAL || type2size[bt] <= 0 ) 1376 return NULL; // Bail out on funny non-value stuff 1377 if( phi->req() <= 3 ) // Need at least 2 matched inputs and a 1378 return NULL; // third unequal input to be worth doing 1379 1380 // Scan for a constant 1381 uint i; 1382 for( i = 1; i < phi->req()-1; i++ ) { 1383 Node *n = phi->in(i); 1384 if( !n ) return NULL; 1385 if( phase->type(n) == Type::TOP ) return NULL; 1386 if( n->Opcode() == Op_ConP || n->Opcode() == Op_ConN ) 1387 break; 1388 } 1389 if( i >= phi->req() ) // Only split for constants 1390 return NULL; 1391 1392 Node *val = phi->in(i); // Constant to split for 1393 uint hit = 0; // Number of times it occurs 1394 Node *r = phi->region(); 1395 1396 for( ; i < phi->req(); i++ ){ // Count occurrences of constant 1397 Node *n = phi->in(i); 1398 if( !n ) return NULL; 1399 if( phase->type(n) == Type::TOP ) return NULL; 1400 if( phi->in(i) == val ) { 1401 hit++; 1402 if (PhaseIdealLoop::find_predicate(r->in(i)) != NULL) { 1403 return NULL; // don't split loop entry path 1404 } 1405 } 1406 } 1407 1408 if( hit <= 1 || // Make sure we find 2 or more 1409 hit == phi->req()-1 ) // and not ALL the same value 1410 return NULL; 1411 1412 // Now start splitting out the flow paths that merge the same value. 1413 // Split first the RegionNode. 1414 PhaseIterGVN *igvn = phase->is_IterGVN(); 1415 RegionNode *newr = new (phase->C, hit+1) RegionNode(hit+1); 1416 split_once(igvn, phi, val, r, newr); 1417 1418 // Now split all other Phis than this one 1419 for (DUIterator_Fast kmax, k = r->fast_outs(kmax); k < kmax; k++) { 1420 Node* phi2 = r->fast_out(k); 1421 if( phi2->is_Phi() && phi2->as_Phi() != phi ) { 1422 PhiNode *newphi = PhiNode::make_blank(newr, phi2); 1423 split_once(igvn, phi, val, phi2, newphi); 1424 } 1425 } 1426 1427 // Clean up this guy 1428 igvn->hash_delete(phi); 1429 for( i = phi->req()-1; i > 0; i-- ) { 1430 if( phi->in(i) == val ) { 1431 phi->del_req(i); 1432 } 1433 } 1434 phi->add_req(val); |