< prev index next >

src/hotspot/share/opto/superword.cpp

Print this page




1428     set_alignment(u1, u2, align);
1429     changed = true;
1430   }
1431   return changed;
1432 }
1433 
1434 //------------------------------order_def_uses---------------------------
1435 // For extended packsets, ordinally arrange uses packset by major component
1436 void SuperWord::order_def_uses(Node_List* p) {
1437   Node* s1 = p->at(0);
1438 
1439   if (s1->is_Store()) return;
1440 
1441   // reductions are always managed beforehand
1442   if (s1->is_reduction()) return;
1443 
1444   for (DUIterator_Fast imax, i = s1->fast_outs(imax); i < imax; i++) {
1445     Node* t1 = s1->fast_out(i);
1446 
1447     // Only allow operand swap on commuting operations
1448     if (!t1->is_Add() && !t1->is_Mul()) {
1449       break;
1450     }
1451 
1452     // Now find t1's packset
1453     Node_List* p2 = NULL;
1454     for (int j = 0; j < _packset.length(); j++) {
1455       p2 = _packset.at(j);
1456       Node* first = p2->at(0);
1457       if (t1 == first) {
1458         break;
1459       }
1460       p2 = NULL;
1461     }
1462     // Arrange all sub components by the major component
1463     if (p2 != NULL) {
1464       for (uint j = 1; j < p->size(); j++) {
1465         Node* d1 = p->at(j);
1466         Node* u1 = p2->at(j);
1467         opnd_positions_match(s1, t1, d1, u1);
1468       }


1483     }
1484     // ensure reductions have phis and reduction definitions feeding the 1st operand
1485     first = u2->in(2);
1486     if (first->is_Phi() || first->is_reduction()) {
1487       u2->swap_edges(1, 2);
1488     }
1489     return true;
1490   }
1491 
1492   uint ct = u1->req();
1493   if (ct != u2->req()) return false;
1494   uint i1 = 0;
1495   uint i2 = 0;
1496   do {
1497     for (i1++; i1 < ct; i1++) if (u1->in(i1) == d1) break;
1498     for (i2++; i2 < ct; i2++) if (u2->in(i2) == d2) break;
1499     if (i1 != i2) {
1500       if ((i1 == (3-i2)) && (u2->is_Add() || u2->is_Mul())) {
1501         // Further analysis relies on operands position matching.
1502         u2->swap_edges(i1, i2);










1503       } else {
1504         return false;
1505       }




1506     }
1507   } while (i1 < ct);
1508   return true;
1509 }
1510 
1511 //------------------------------est_savings---------------------------
1512 // Estimate the savings from executing s1 and s2 as a pack
1513 int SuperWord::est_savings(Node* s1, Node* s2) {
1514   int save_in = 2 - 1; // 2 operations per instruction in packed form
1515 
1516   // inputs
1517   for (uint i = 1; i < s1->req(); i++) {
1518     Node* x1 = s1->in(i);
1519     Node* x2 = s2->in(i);
1520     if (x1 != x2) {
1521       if (are_adjacent_refs(x1, x2)) {
1522         save_in += adjacent_profit(x1, x2);
1523       } else if (!in_packset(x1, x2)) {
1524         save_in -= pack_cost(2);
1525       } else {




1428     set_alignment(u1, u2, align);
1429     changed = true;
1430   }
1431   return changed;
1432 }
1433 
1434 //------------------------------order_def_uses---------------------------
1435 // For extended packsets, ordinally arrange uses packset by major component
1436 void SuperWord::order_def_uses(Node_List* p) {
1437   Node* s1 = p->at(0);
1438 
1439   if (s1->is_Store()) return;
1440 
1441   // reductions are always managed beforehand
1442   if (s1->is_reduction()) return;
1443 
1444   for (DUIterator_Fast imax, i = s1->fast_outs(imax); i < imax; i++) {
1445     Node* t1 = s1->fast_out(i);
1446 
1447     // Only allow operand swap on commuting operations
1448     if (!t1->is_Add() && !t1->is_Mul() && !VectorNode::is_muladds2i(t1)) {
1449       break;
1450     }
1451 
1452     // Now find t1's packset
1453     Node_List* p2 = NULL;
1454     for (int j = 0; j < _packset.length(); j++) {
1455       p2 = _packset.at(j);
1456       Node* first = p2->at(0);
1457       if (t1 == first) {
1458         break;
1459       }
1460       p2 = NULL;
1461     }
1462     // Arrange all sub components by the major component
1463     if (p2 != NULL) {
1464       for (uint j = 1; j < p->size(); j++) {
1465         Node* d1 = p->at(j);
1466         Node* u1 = p2->at(j);
1467         opnd_positions_match(s1, t1, d1, u1);
1468       }


1483     }
1484     // ensure reductions have phis and reduction definitions feeding the 1st operand
1485     first = u2->in(2);
1486     if (first->is_Phi() || first->is_reduction()) {
1487       u2->swap_edges(1, 2);
1488     }
1489     return true;
1490   }
1491 
1492   uint ct = u1->req();
1493   if (ct != u2->req()) return false;
1494   uint i1 = 0;
1495   uint i2 = 0;
1496   do {
1497     for (i1++; i1 < ct; i1++) if (u1->in(i1) == d1) break;
1498     for (i2++; i2 < ct; i2++) if (u2->in(i2) == d2) break;
1499     if (i1 != i2) {
1500       if ((i1 == (3-i2)) && (u2->is_Add() || u2->is_Mul())) {
1501         // Further analysis relies on operands position matching.
1502         u2->swap_edges(i1, i2);
1503       } else if (VectorNode::is_muladds2i(u2) && u1 != u2) {
1504         if (i1 == 5 - i2) { // ((i1 == 3 && i2 == 2) || (i1 == 2 && i2 == 3) || (i1 == 1 && i2 == 4) || (i1 == 4 && i2 == 1))
1505           u2->swap_edges(1, 2);
1506           u2->swap_edges(3, 4);
1507         }
1508         if (i1 == 3 - i2 || i1 == 7 - i2) { // ((i1 == 1 && i2 == 2) || (i1 == 2 && i2 == 1) || (i1 == 3 && i2 == 4) || (i1 == 4 && i2 == 3))
1509           u2->swap_edges(2, 3);
1510           u2->swap_edges(1, 4);
1511         }
1512         return false; // Just swap the edges, the muladds2i nodes get packed in follow_use_defs
1513       } else {
1514         return false;
1515       }
1516     } else if (i1 == i2 && VectorNode::is_muladds2i(u2) && u1 != u2) {
1517       u2->swap_edges(1, 3);
1518       u2->swap_edges(2, 4);
1519       return false; // Just swap the edges, the muladds2i nodes get packed in follow_use_defs
1520     }
1521   } while (i1 < ct);
1522   return true;
1523 }
1524 
1525 //------------------------------est_savings---------------------------
1526 // Estimate the savings from executing s1 and s2 as a pack
1527 int SuperWord::est_savings(Node* s1, Node* s2) {
1528   int save_in = 2 - 1; // 2 operations per instruction in packed form
1529 
1530   // inputs
1531   for (uint i = 1; i < s1->req(); i++) {
1532     Node* x1 = s1->in(i);
1533     Node* x2 = s2->in(i);
1534     if (x1 != x2) {
1535       if (are_adjacent_refs(x1, x2)) {
1536         save_in += adjacent_profit(x1, x2);
1537       } else if (!in_packset(x1, x2)) {
1538         save_in -= pack_cost(2);
1539       } else {


< prev index next >