< prev index next >

src/hotspot/share/opto/vectornode.cpp

Print this page
rev 53101 : 8214922: Add vectorization support for fmin/fmax
Reviewed-by: duke


 161     case T_SHORT:  return 0; // Vector logical right shift for signed short
 162                              // values produces incorrect Java result for
 163                              // negative data because java code should convert
 164                              // a short value into int value with sign
 165                              // extension before a shift.
 166     case T_INT:    return Op_URShiftVI;
 167     default:       ShouldNotReachHere(); return 0;
 168     }
 169   case Op_URShiftL:
 170     assert(bt == T_LONG, "must be");
 171     return Op_URShiftVL;
 172   case Op_AndI:
 173   case Op_AndL:
 174     return Op_AndV;
 175   case Op_OrI:
 176   case Op_OrL:
 177     return Op_OrV;
 178   case Op_XorI:
 179   case Op_XorL:
 180     return Op_XorV;












 181 
 182   case Op_LoadB:
 183   case Op_LoadUB:
 184   case Op_LoadUS:
 185   case Op_LoadS:
 186   case Op_LoadI:
 187   case Op_LoadL:
 188   case Op_LoadF:
 189   case Op_LoadD:
 190     return Op_LoadVector;
 191 
 192   case Op_StoreB:
 193   case Op_StoreC:
 194   case Op_StoreI:
 195   case Op_StoreL:
 196   case Op_StoreF:
 197   case Op_StoreD:
 198     return Op_StoreVector;
 199   case Op_MulAddS2I:
 200     return Op_MulAddVS2VI;


 360 
 361   case Op_LShiftVB: return new LShiftVBNode(n1, n2, vt);
 362   case Op_LShiftVS: return new LShiftVSNode(n1, n2, vt);
 363   case Op_LShiftVI: return new LShiftVINode(n1, n2, vt);
 364   case Op_LShiftVL: return new LShiftVLNode(n1, n2, vt);
 365 
 366   case Op_RShiftVB: return new RShiftVBNode(n1, n2, vt);
 367   case Op_RShiftVS: return new RShiftVSNode(n1, n2, vt);
 368   case Op_RShiftVI: return new RShiftVINode(n1, n2, vt);
 369   case Op_RShiftVL: return new RShiftVLNode(n1, n2, vt);
 370 
 371   case Op_URShiftVB: return new URShiftVBNode(n1, n2, vt);
 372   case Op_URShiftVS: return new URShiftVSNode(n1, n2, vt);
 373   case Op_URShiftVI: return new URShiftVINode(n1, n2, vt);
 374   case Op_URShiftVL: return new URShiftVLNode(n1, n2, vt);
 375 
 376   case Op_AndV: return new AndVNode(n1, n2, vt);
 377   case Op_OrV:  return new OrVNode (n1, n2, vt);
 378   case Op_XorV: return new XorVNode(n1, n2, vt);
 379 



 380   case Op_MulAddVS2VI: return new MulAddVS2VINode(n1, n2, vt);
 381   default:
 382     fatal("Missed vector creation for '%s'", NodeClassNames[vopc]);
 383     return NULL;
 384   }
 385 }
 386 
 387 VectorNode* VectorNode::make(int opc, Node* n1, Node* n2, Node* n3, uint vlen, BasicType bt) {
 388   const TypeVect* vt = TypeVect::make(bt, vlen);
 389   int vopc = VectorNode::opcode(opc, bt);
 390   // This method should not be called for unimplemented vectors.
 391   guarantee(vopc > 0, "Vector for '%s' is not implemented", NodeClassNames[opc]);
 392   switch (vopc) {
 393   case Op_FmaVD: return new FmaVDNode(n1, n2, n3, vt);
 394   case Op_FmaVF: return new FmaVFNode(n1, n2, n3, vt);
 395   default:
 396     fatal("Missed vector creation for '%s'", NodeClassNames[vopc]);
 397     return NULL;
 398   }
 399 }


 565     case Op_AddD:
 566       assert(bt == T_DOUBLE, "must be");
 567       vopc = Op_AddReductionVD;
 568       break;
 569     case Op_MulI:
 570       assert(bt == T_INT, "must be");
 571       vopc = Op_MulReductionVI;
 572       break;
 573     case Op_MulL:
 574       assert(bt == T_LONG, "must be");
 575       vopc = Op_MulReductionVL;
 576       break;
 577     case Op_MulF:
 578       assert(bt == T_FLOAT, "must be");
 579       vopc = Op_MulReductionVF;
 580       break;
 581     case Op_MulD:
 582       assert(bt == T_DOUBLE, "must be");
 583       vopc = Op_MulReductionVD;
 584       break;
















 585     // TODO: add MulL for targets that support it
 586     default:
 587       break;
 588   }
 589   return vopc;
 590 }
 591 
 592 // Return the appropriate reduction node.
 593 ReductionNode* ReductionNode::make(int opc, Node *ctrl, Node* n1, Node* n2, BasicType bt) {
 594 
 595   int vopc = opcode(opc, bt);
 596 
 597   // This method should not be called for unimplemented vectors.
 598   guarantee(vopc != opc, "Vector for '%s' is not implemented", NodeClassNames[opc]);
 599 
 600   switch (vopc) {
 601   case Op_AddReductionVI: return new AddReductionVINode(ctrl, n1, n2);
 602   case Op_AddReductionVL: return new AddReductionVLNode(ctrl, n1, n2);
 603   case Op_AddReductionVF: return new AddReductionVFNode(ctrl, n1, n2);
 604   case Op_AddReductionVD: return new AddReductionVDNode(ctrl, n1, n2);
 605   case Op_MulReductionVI: return new MulReductionVINode(ctrl, n1, n2);
 606   case Op_MulReductionVL: return new MulReductionVLNode(ctrl, n1, n2);
 607   case Op_MulReductionVF: return new MulReductionVFNode(ctrl, n1, n2);
 608   case Op_MulReductionVD: return new MulReductionVDNode(ctrl, n1, n2);


 609   default:
 610     fatal("Missed vector creation for '%s'", NodeClassNames[vopc]);
 611     return NULL;
 612   }
 613 }
 614 
 615 bool ReductionNode::implemented(int opc, uint vlen, BasicType bt) {
 616   if (is_java_primitive(bt) &&
 617       (vlen > 1) && is_power_of_2(vlen) &&
 618       Matcher::vector_size_supported(bt, vlen)) {
 619     int vopc = ReductionNode::opcode(opc, bt);
 620     return vopc != opc && Matcher::match_rule_supported(vopc);
 621   }
 622   return false;
 623 }


 161     case T_SHORT:  return 0; // Vector logical right shift for signed short
 162                              // values produces incorrect Java result for
 163                              // negative data because java code should convert
 164                              // a short value into int value with sign
 165                              // extension before a shift.
 166     case T_INT:    return Op_URShiftVI;
 167     default:       ShouldNotReachHere(); return 0;
 168     }
 169   case Op_URShiftL:
 170     assert(bt == T_LONG, "must be");
 171     return Op_URShiftVL;
 172   case Op_AndI:
 173   case Op_AndL:
 174     return Op_AndV;
 175   case Op_OrI:
 176   case Op_OrL:
 177     return Op_OrV;
 178   case Op_XorI:
 179   case Op_XorL:
 180     return Op_XorV;
 181   case Op_MinF:
 182     assert(bt == T_FLOAT, "must be");
 183     return Op_MinV;
 184   case Op_MinD:
 185     assert(bt == T_DOUBLE, "must be");
 186     return Op_MinV;
 187   case Op_MaxF:
 188     assert(bt == T_FLOAT, "must be");
 189     return Op_MaxV;
 190   case Op_MaxD:
 191     assert(bt == T_DOUBLE, "must be");
 192     return Op_MaxV;
 193 
 194   case Op_LoadB:
 195   case Op_LoadUB:
 196   case Op_LoadUS:
 197   case Op_LoadS:
 198   case Op_LoadI:
 199   case Op_LoadL:
 200   case Op_LoadF:
 201   case Op_LoadD:
 202     return Op_LoadVector;
 203 
 204   case Op_StoreB:
 205   case Op_StoreC:
 206   case Op_StoreI:
 207   case Op_StoreL:
 208   case Op_StoreF:
 209   case Op_StoreD:
 210     return Op_StoreVector;
 211   case Op_MulAddS2I:
 212     return Op_MulAddVS2VI;


 372 
 373   case Op_LShiftVB: return new LShiftVBNode(n1, n2, vt);
 374   case Op_LShiftVS: return new LShiftVSNode(n1, n2, vt);
 375   case Op_LShiftVI: return new LShiftVINode(n1, n2, vt);
 376   case Op_LShiftVL: return new LShiftVLNode(n1, n2, vt);
 377 
 378   case Op_RShiftVB: return new RShiftVBNode(n1, n2, vt);
 379   case Op_RShiftVS: return new RShiftVSNode(n1, n2, vt);
 380   case Op_RShiftVI: return new RShiftVINode(n1, n2, vt);
 381   case Op_RShiftVL: return new RShiftVLNode(n1, n2, vt);
 382 
 383   case Op_URShiftVB: return new URShiftVBNode(n1, n2, vt);
 384   case Op_URShiftVS: return new URShiftVSNode(n1, n2, vt);
 385   case Op_URShiftVI: return new URShiftVINode(n1, n2, vt);
 386   case Op_URShiftVL: return new URShiftVLNode(n1, n2, vt);
 387 
 388   case Op_AndV: return new AndVNode(n1, n2, vt);
 389   case Op_OrV:  return new OrVNode (n1, n2, vt);
 390   case Op_XorV: return new XorVNode(n1, n2, vt);
 391 
 392   case Op_MinV: return new MinVNode(n1, n2, vt);
 393   case Op_MaxV: return new MaxVNode(n1, n2, vt);
 394 
 395   case Op_MulAddVS2VI: return new MulAddVS2VINode(n1, n2, vt);
 396   default:
 397     fatal("Missed vector creation for '%s'", NodeClassNames[vopc]);
 398     return NULL;
 399   }
 400 }
 401 
 402 VectorNode* VectorNode::make(int opc, Node* n1, Node* n2, Node* n3, uint vlen, BasicType bt) {
 403   const TypeVect* vt = TypeVect::make(bt, vlen);
 404   int vopc = VectorNode::opcode(opc, bt);
 405   // This method should not be called for unimplemented vectors.
 406   guarantee(vopc > 0, "Vector for '%s' is not implemented", NodeClassNames[opc]);
 407   switch (vopc) {
 408   case Op_FmaVD: return new FmaVDNode(n1, n2, n3, vt);
 409   case Op_FmaVF: return new FmaVFNode(n1, n2, n3, vt);
 410   default:
 411     fatal("Missed vector creation for '%s'", NodeClassNames[vopc]);
 412     return NULL;
 413   }
 414 }


 580     case Op_AddD:
 581       assert(bt == T_DOUBLE, "must be");
 582       vopc = Op_AddReductionVD;
 583       break;
 584     case Op_MulI:
 585       assert(bt == T_INT, "must be");
 586       vopc = Op_MulReductionVI;
 587       break;
 588     case Op_MulL:
 589       assert(bt == T_LONG, "must be");
 590       vopc = Op_MulReductionVL;
 591       break;
 592     case Op_MulF:
 593       assert(bt == T_FLOAT, "must be");
 594       vopc = Op_MulReductionVF;
 595       break;
 596     case Op_MulD:
 597       assert(bt == T_DOUBLE, "must be");
 598       vopc = Op_MulReductionVD;
 599       break;
 600     case Op_MinF:
 601       assert(bt == T_FLOAT, "must be");
 602       vopc = Op_MinReductionV;
 603       break;
 604     case Op_MinD:
 605       assert(bt == T_DOUBLE, "must be");
 606       vopc = Op_MaxReductionV;
 607       break;
 608     case Op_MaxF:
 609       assert(bt == T_FLOAT, "must be");
 610       vopc = Op_MinReductionV;
 611       break;
 612     case Op_MaxD:
 613       assert(bt == T_DOUBLE, "must be");
 614       vopc = Op_MaxReductionV;
 615       break;
 616     // TODO: add MulL for targets that support it
 617     default:
 618       break;
 619   }
 620   return vopc;
 621 }
 622 
 623 // Return the appropriate reduction node.
 624 ReductionNode* ReductionNode::make(int opc, Node *ctrl, Node* n1, Node* n2, BasicType bt) {
 625 
 626   int vopc = opcode(opc, bt);
 627 
 628   // This method should not be called for unimplemented vectors.
 629   guarantee(vopc != opc, "Vector for '%s' is not implemented", NodeClassNames[opc]);
 630 
 631   switch (vopc) {
 632   case Op_AddReductionVI: return new AddReductionVINode(ctrl, n1, n2);
 633   case Op_AddReductionVL: return new AddReductionVLNode(ctrl, n1, n2);
 634   case Op_AddReductionVF: return new AddReductionVFNode(ctrl, n1, n2);
 635   case Op_AddReductionVD: return new AddReductionVDNode(ctrl, n1, n2);
 636   case Op_MulReductionVI: return new MulReductionVINode(ctrl, n1, n2);
 637   case Op_MulReductionVL: return new MulReductionVLNode(ctrl, n1, n2);
 638   case Op_MulReductionVF: return new MulReductionVFNode(ctrl, n1, n2);
 639   case Op_MulReductionVD: return new MulReductionVDNode(ctrl, n1, n2);
 640   case Op_MinReductionV: return new MinReductionVNode(ctrl, n1, n2);
 641   case Op_MaxReductionV: return new MaxReductionVNode(ctrl, n1, n2);
 642   default:
 643     fatal("Missed vector creation for '%s'", NodeClassNames[vopc]);
 644     return NULL;
 645   }
 646 }
 647 
 648 bool ReductionNode::implemented(int opc, uint vlen, BasicType bt) {
 649   if (is_java_primitive(bt) &&
 650       (vlen > 1) && is_power_of_2(vlen) &&
 651       Matcher::vector_size_supported(bt, vlen)) {
 652     int vopc = ReductionNode::opcode(opc, bt);
 653     return vopc != opc && Matcher::match_rule_supported(vopc);
 654   }
 655   return false;
 656 }
< prev index next >