comparison src/share/vm/opto/superword.cpp @ 6619:5af51c882207

7192963: assert(_in[req-1] == this) failed: Must pass arg count to 'new' Summary: Fixed Pack node generation. Not vectorize shift instructions if count is not the same for all shifts and if count is vector. Reviewed-by: twisti
author kvn
date Wed, 22 Aug 2012 11:55:40 -0700
parents 4b0d6fd74911
children 137868b7aa6f
comparison
equal deleted inserted replaced
6618:0bfcb7a3e12d 6619:5af51c882207
1053 1053
1054 //------------------------------implemented--------------------------- 1054 //------------------------------implemented---------------------------
1055 // Can code be generated for pack p? 1055 // Can code be generated for pack p?
1056 bool SuperWord::implemented(Node_List* p) { 1056 bool SuperWord::implemented(Node_List* p) {
1057 Node* p0 = p->at(0); 1057 Node* p0 = p->at(0);
1058 if (VectorNode::is_shift(p0) && in_bb(p0->in(2))) {
1059 return false; // vector shift count should be loop's invariant.
1060 }
1061 return VectorNode::implemented(p0->Opcode(), p->size(), velt_basic_type(p0)); 1058 return VectorNode::implemented(p0->Opcode(), p->size(), velt_basic_type(p0));
1059 }
1060
1061 //------------------------------same_inputs--------------------------
1062 // For pack p, are all idx operands the same?
1063 static bool same_inputs(Node_List* p, int idx) {
1064 Node* p0 = p->at(0);
1065 uint vlen = p->size();
1066 Node* p0_def = p0->in(idx);
1067 for (uint i = 1; i < vlen; i++) {
1068 Node* pi = p->at(i);
1069 Node* pi_def = pi->in(idx);
1070 if (p0_def != pi_def)
1071 return false;
1072 }
1073 return true;
1062 } 1074 }
1063 1075
1064 //------------------------------profitable--------------------------- 1076 //------------------------------profitable---------------------------
1065 // For pack p, are all operands and all uses (with in the block) vector? 1077 // For pack p, are all operands and all uses (with in the block) vector?
1066 bool SuperWord::profitable(Node_List* p) { 1078 bool SuperWord::profitable(Node_List* p) {
1067 Node* p0 = p->at(0); 1079 Node* p0 = p->at(0);
1068 uint start, end; 1080 uint start, end;
1069 vector_opd_range(p0, &start, &end); 1081 VectorNode::vector_operands(p0, &start, &end);
1070 1082
1071 // Return false if some input is not vector and inside block 1083 // Return false if some input is not vector and inside block
1072 for (uint i = start; i < end; i++) { 1084 for (uint i = start; i < end; i++) {
1073 if (!is_vector_use(p0, i)) { 1085 if (!is_vector_use(p0, i)) {
1074 // For now, return false if not scalar promotion case (inputs are the same.) 1086 // For now, return false if not scalar promotion case (inputs are the same.)
1075 // Later, implement PackNode and allow differing, non-vector inputs 1087 // Later, implement PackNode and allow differing, non-vector inputs
1076 // (maybe just the ones from outside the block.) 1088 // (maybe just the ones from outside the block.)
1077 Node* p0_def = p0->in(i); 1089 if (!same_inputs(p, i)) {
1078 for (uint j = 1; j < p->size(); j++) { 1090 return false;
1079 Node* use = p->at(j); 1091 }
1080 Node* def = use->in(i); 1092 }
1081 if (p0_def != def) 1093 }
1082 return false; 1094 if (VectorNode::is_shift(p0)) {
1083 } 1095 // For now, return false if shift count is vector because
1084 } 1096 // hw does not support it.
1097 if (is_vector_use(p0, 2))
1098 return false;
1099 // For the same reason return false if different shift counts.
1100 if (!same_inputs(p, 2))
1101 return false;
1085 } 1102 }
1086 if (!p0->is_Store()) { 1103 if (!p0->is_Store()) {
1087 // For now, return false if not all uses are vector. 1104 // For now, return false if not all uses are vector.
1088 // Later, implement ExtractNode and allow non-vector uses (maybe 1105 // Later, implement ExtractNode and allow non-vector uses (maybe
1089 // just the ones outside the block.) 1106 // just the ones outside the block.)
1393 Node* SuperWord::vector_opd(Node_List* p, int opd_idx) { 1410 Node* SuperWord::vector_opd(Node_List* p, int opd_idx) {
1394 Node* p0 = p->at(0); 1411 Node* p0 = p->at(0);
1395 uint vlen = p->size(); 1412 uint vlen = p->size();
1396 Node* opd = p0->in(opd_idx); 1413 Node* opd = p0->in(opd_idx);
1397 1414
1398 bool same_opd = true; 1415 if (same_inputs(p, opd_idx)) {
1399 for (uint i = 1; i < vlen; i++) {
1400 Node* pi = p->at(i);
1401 Node* in = pi->in(opd_idx);
1402 if (opd != in) {
1403 same_opd = false;
1404 break;
1405 }
1406 }
1407
1408 if (same_opd) {
1409 if (opd->is_Vector() || opd->is_LoadVector()) { 1416 if (opd->is_Vector() || opd->is_LoadVector()) {
1410 assert(((opd_idx != 2) || !VectorNode::is_shift(p0)), "shift's count can't be vector"); 1417 assert(((opd_idx != 2) || !VectorNode::is_shift(p0)), "shift's count can't be vector");
1411 return opd; // input is matching vector 1418 return opd; // input is matching vector
1412 } 1419 }
1413 if ((opd_idx == 2) && VectorNode::is_shift(p0)) { 1420 if ((opd_idx == 2) && VectorNode::is_shift(p0)) {
1466 for (uint i = 1; i < vlen; i++) { 1473 for (uint i = 1; i < vlen; i++) {
1467 Node* pi = p->at(i); 1474 Node* pi = p->at(i);
1468 Node* in = pi->in(opd_idx); 1475 Node* in = pi->in(opd_idx);
1469 assert(my_pack(in) == NULL, "Should already have been unpacked"); 1476 assert(my_pack(in) == NULL, "Should already have been unpacked");
1470 assert(opd_bt == in->bottom_type()->basic_type(), "all same type"); 1477 assert(opd_bt == in->bottom_type()->basic_type(), "all same type");
1471 pk->add_opd(i, in); 1478 pk->add_opd(in);
1472 } 1479 }
1473 _phase->_igvn.register_new_node_with_optimizer(pk); 1480 _phase->_igvn.register_new_node_with_optimizer(pk);
1474 _phase->set_ctrl(pk, _phase->get_ctrl(opd)); 1481 _phase->set_ctrl(pk, _phase->get_ctrl(opd));
1475 #ifdef ASSERT 1482 #ifdef ASSERT
1476 if (TraceNewVectors) { 1483 if (TraceNewVectors) {
1759 Node* n = _block.at(i); 1766 Node* n = _block.at(i);
1760 // Only integer types need be examined 1767 // Only integer types need be examined
1761 const Type* vt = velt_type(n); 1768 const Type* vt = velt_type(n);
1762 if (vt->basic_type() == T_INT) { 1769 if (vt->basic_type() == T_INT) {
1763 uint start, end; 1770 uint start, end;
1764 vector_opd_range(n, &start, &end); 1771 VectorNode::vector_operands(n, &start, &end);
1765 const Type* vt = velt_type(n); 1772 const Type* vt = velt_type(n);
1766 1773
1767 for (uint j = start; j < end; j++) { 1774 for (uint j = start; j < end; j++) {
1768 Node* in = n->in(j); 1775 Node* in = n->in(j);
1769 // Don't propagate through a memory 1776 // Don't propagate through a memory
1835 if (vt1->basic_type() == T_INT && vt2->basic_type() == T_INT) { 1842 if (vt1->basic_type() == T_INT && vt2->basic_type() == T_INT) {
1836 // Compare vectors element sizes for integer types. 1843 // Compare vectors element sizes for integer types.
1837 return data_size(n1) == data_size(n2); 1844 return data_size(n1) == data_size(n2);
1838 } 1845 }
1839 return vt1 == vt2; 1846 return vt1 == vt2;
1840 }
1841
1842 //-------------------------vector_opd_range-----------------------
1843 // (Start, end] half-open range defining which operands are vector
1844 void SuperWord::vector_opd_range(Node* n, uint* start, uint* end) {
1845 switch (n->Opcode()) {
1846 case Op_LoadB: case Op_LoadUB:
1847 case Op_LoadS: case Op_LoadUS:
1848 case Op_LoadI: case Op_LoadL:
1849 case Op_LoadF: case Op_LoadD:
1850 case Op_LoadP:
1851 *start = 0;
1852 *end = 0;
1853 return;
1854 case Op_StoreB: case Op_StoreC:
1855 case Op_StoreI: case Op_StoreL:
1856 case Op_StoreF: case Op_StoreD:
1857 case Op_StoreP:
1858 *start = MemNode::ValueIn;
1859 *end = *start + 1;
1860 return;
1861 case Op_LShiftI: case Op_LShiftL:
1862 *start = 1;
1863 *end = 2;
1864 return;
1865 case Op_CMoveI: case Op_CMoveL: case Op_CMoveF: case Op_CMoveD:
1866 *start = 2;
1867 *end = n->req();
1868 return;
1869 }
1870 *start = 1;
1871 *end = n->req(); // default is all operands
1872 } 1847 }
1873 1848
1874 //------------------------------in_packset--------------------------- 1849 //------------------------------in_packset---------------------------
1875 // Are s1 and s2 in a pack pair and ordered as s1,s2? 1850 // Are s1 and s2 in a pack pair and ordered as s1,s2?
1876 bool SuperWord::in_packset(Node* s1, Node* s2) { 1851 bool SuperWord::in_packset(Node* s1, Node* s2) {