1 /*
   2  * Copyright (c) 2007, 2017, Oracle and/or its affiliates. All rights reserved.
   3  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
   4  *
   5  * This code is free software; you can redistribute it and/or modify it
   6  * under the terms of the GNU General Public License version 2 only, as
   7  * published by the Free Software Foundation.
   8  *
   9  * This code is distributed in the hope that it will be useful, but WITHOUT
  10  * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
  11  * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
  12  * version 2 for more details (a copy is included in the LICENSE file that
  13  * accompanied this code).
  14  *
  15  * You should have received a copy of the GNU General Public License version
  16  * 2 along with this work; if not, write to the Free Software Foundation,
  17  * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
  18  *
  19  * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
  20  * or visit www.oracle.com if you need additional information or have any
  21  * questions.
  22  */
  23 
  24 #include "precompiled.hpp"
  25 #include "memory/allocation.inline.hpp"
  26 #include "opto/connode.hpp"
  27 #include "opto/vectornode.hpp"
  28 
  29 //------------------------------VectorNode--------------------------------------
  30 
  31 // Return the vector operator for the specified scalar operation
  32 // and vector length.
  33 int VectorNode::opcode(int sopc, BasicType bt) {
  34   switch (sopc) {
  35   case Op_AddI:
  36     switch (bt) {
  37     case T_BOOLEAN:
  38     case T_BYTE:      return Op_AddVB;
  39     case T_CHAR:
  40     case T_SHORT:     return Op_AddVS;
  41     case T_INT:       return Op_AddVI;
  42     default:          ShouldNotReachHere(); return 0;
  43     }
  44   case Op_AddL:
  45     assert(bt == T_LONG, "must be");
  46     return Op_AddVL;
  47   case Op_AddF:
  48     assert(bt == T_FLOAT, "must be");
  49     return Op_AddVF;
  50   case Op_AddD:
  51     assert(bt == T_DOUBLE, "must be");
  52     return Op_AddVD;
  53   case Op_SubI:
  54     switch (bt) {
  55     case T_BOOLEAN:
  56     case T_BYTE:   return Op_SubVB;
  57     case T_CHAR:
  58     case T_SHORT:  return Op_SubVS;
  59     case T_INT:    return Op_SubVI;
  60     default:       ShouldNotReachHere(); return 0;
  61     }
  62   case Op_SubL:
  63     assert(bt == T_LONG, "must be");
  64     return Op_SubVL;
  65   case Op_SubF:
  66     assert(bt == T_FLOAT, "must be");
  67     return Op_SubVF;
  68   case Op_SubD:
  69     assert(bt == T_DOUBLE, "must be");
  70     return Op_SubVD;
  71   case Op_MulI:
  72     switch (bt) {
  73     case T_BOOLEAN:
  74     case T_BYTE:   return 0;   // Unimplemented
  75     case T_CHAR:
  76     case T_SHORT:  return Op_MulVS;
  77     case T_INT:    return Op_MulVI;
  78     default:       ShouldNotReachHere(); return 0;
  79     }
  80   case Op_MulL:
  81     assert(bt == T_LONG, "must be");
  82     return Op_MulVL;
  83   case Op_MulF:
  84     assert(bt == T_FLOAT, "must be");
  85     return Op_MulVF;
  86   case Op_MulD:
  87     assert(bt == T_DOUBLE, "must be");
  88     return Op_MulVD;
  89   case Op_FmaD:
  90     assert(bt == T_DOUBLE, "must be");
  91     return Op_FmaVD;
  92   case Op_FmaF:
  93     assert(bt == T_FLOAT, "must be");
  94     return Op_FmaVF;
  95   case Op_CMoveF:
  96     assert(bt == T_FLOAT, "must be");
  97     return Op_CMoveVF;
  98   case Op_CMoveD:
  99     assert(bt == T_DOUBLE, "must be");
 100     return Op_CMoveVD;
 101   case Op_DivF:
 102     assert(bt == T_FLOAT, "must be");
 103     return Op_DivVF;
 104   case Op_DivD:
 105     assert(bt == T_DOUBLE, "must be");
 106     return Op_DivVD;
 107   case Op_AbsF:
 108     assert(bt == T_FLOAT, "must be");
 109     return Op_AbsVF;
 110   case Op_AbsD:
 111     assert(bt == T_DOUBLE, "must be");
 112     return Op_AbsVD;
 113   case Op_NegF:
 114     assert(bt == T_FLOAT, "must be");
 115     return Op_NegVF;
 116   case Op_NegD:
 117     assert(bt == T_DOUBLE, "must be");
 118     return Op_NegVD;
 119   case Op_SqrtF:
 120     assert(bt == T_FLOAT, "must be");
 121     return Op_SqrtVF;
 122   case Op_SqrtD:
 123     assert(bt == T_DOUBLE, "must be");
 124     return Op_SqrtVD;
 125   case Op_PopCountI:
 126     if (bt == T_INT) {
 127       return Op_PopCountVI;
 128     }
 129     // Unimplemented for subword types since bit count changes
 130     // depending on size of lane (and sign bit).
 131     return 0;
 132   case Op_LShiftI:
 133     switch (bt) {
 134     case T_BOOLEAN:
 135     case T_BYTE:   return Op_LShiftVB;
 136     case T_CHAR:
 137     case T_SHORT:  return Op_LShiftVS;
 138     case T_INT:    return Op_LShiftVI;
 139       default:       ShouldNotReachHere(); return 0;
 140     }
 141   case Op_LShiftL:
 142     assert(bt == T_LONG, "must be");
 143     return Op_LShiftVL;
 144   case Op_RShiftI:
 145     switch (bt) {
 146     case T_BOOLEAN:return Op_URShiftVB; // boolean is unsigned value
 147     case T_CHAR:   return Op_URShiftVS; // char is unsigned value
 148     case T_BYTE:   return Op_RShiftVB;
 149     case T_SHORT:  return Op_RShiftVS;
 150     case T_INT:    return Op_RShiftVI;
 151     default:       ShouldNotReachHere(); return 0;
 152     }
 153   case Op_RShiftL:
 154     assert(bt == T_LONG, "must be");
 155     return Op_RShiftVL;
 156   case Op_URShiftI:
 157     switch (bt) {
 158     case T_BOOLEAN:return Op_URShiftVB;
 159     case T_CHAR:   return Op_URShiftVS;
 160     case T_BYTE:
 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;
 201 
 202   default:
 203     return 0; // Unimplemented
 204   }
 205 }
 206 
 207 // Also used to check if the code generator
 208 // supports the vector operation.
 209 bool VectorNode::implemented(int opc, uint vlen, BasicType bt) {
 210   if (is_java_primitive(bt) &&
 211       (vlen > 1) && is_power_of_2(vlen) &&
 212       Matcher::vector_size_supported(bt, vlen)) {
 213     int vopc = VectorNode::opcode(opc, bt);
 214     return vopc > 0 && Matcher::match_rule_supported_vector(vopc, vlen);
 215   }
 216   return false;
 217 }
 218 
 219 bool VectorNode::is_type_transition_short_to_int(Node* n) {
 220   switch (n->Opcode()) {
 221   case Op_MulAddS2I:
 222     return true;
 223   }
 224   return false;
 225 }
 226 
 227 bool VectorNode::is_type_transition_to_int(Node* n) {
 228   return is_type_transition_short_to_int(n);
 229 }
 230 
 231 bool VectorNode::is_muladds2i(Node* n) {
 232   if (n->Opcode() == Op_MulAddS2I) {
 233     return true;
 234   }
 235   return false;
 236 }
 237 
 238 bool VectorNode::is_shift(Node* n) {
 239   switch (n->Opcode()) {
 240   case Op_LShiftI:
 241   case Op_LShiftL:
 242   case Op_RShiftI:
 243   case Op_RShiftL:
 244   case Op_URShiftI:
 245   case Op_URShiftL:
 246     return true;
 247   default:
 248     return false;
 249   }
 250 }
 251 
 252 // Check if input is loop invariant vector.
 253 bool VectorNode::is_invariant_vector(Node* n) {
 254   // Only Replicate vector nodes are loop invariant for now.
 255   switch (n->Opcode()) {
 256   case Op_ReplicateB:
 257   case Op_ReplicateS:
 258   case Op_ReplicateI:
 259   case Op_ReplicateL:
 260   case Op_ReplicateF:
 261   case Op_ReplicateD:
 262     return true;
 263   default:
 264     return false;
 265   }
 266 }
 267 
 268 // [Start, end) half-open range defining which operands are vectors
 269 void VectorNode::vector_operands(Node* n, uint* start, uint* end) {
 270   switch (n->Opcode()) {
 271   case Op_LoadB:   case Op_LoadUB:
 272   case Op_LoadS:   case Op_LoadUS:
 273   case Op_LoadI:   case Op_LoadL:
 274   case Op_LoadF:   case Op_LoadD:
 275   case Op_LoadP:   case Op_LoadN:
 276   case Op_LoadBarrierSlowReg:
 277   case Op_LoadBarrierWeakSlowReg:
 278     *start = 0;
 279     *end   = 0; // no vector operands
 280     break;
 281   case Op_StoreB:  case Op_StoreC:
 282   case Op_StoreI:  case Op_StoreL:
 283   case Op_StoreF:  case Op_StoreD:
 284   case Op_StoreP:  case Op_StoreN:
 285     *start = MemNode::ValueIn;
 286     *end   = MemNode::ValueIn + 1; // 1 vector operand
 287     break;
 288   case Op_LShiftI:  case Op_LShiftL:
 289   case Op_RShiftI:  case Op_RShiftL:
 290   case Op_URShiftI: case Op_URShiftL:
 291     *start = 1;
 292     *end   = 2; // 1 vector operand
 293     break;
 294   case Op_AddI: case Op_AddL: case Op_AddF: case Op_AddD:
 295   case Op_SubI: case Op_SubL: case Op_SubF: case Op_SubD:
 296   case Op_MulI: case Op_MulL: case Op_MulF: case Op_MulD:
 297   case Op_DivF: case Op_DivD:
 298   case Op_AndI: case Op_AndL:
 299   case Op_OrI:  case Op_OrL:
 300   case Op_XorI: case Op_XorL:
 301   case Op_MulAddS2I:
 302     *start = 1;
 303     *end   = 3; // 2 vector operands
 304     break;
 305   case Op_CMoveI:  case Op_CMoveL:  case Op_CMoveF:  case Op_CMoveD:
 306     *start = 2;
 307     *end   = n->req();
 308     break;
 309   case Op_FmaD:
 310   case Op_FmaF:
 311     *start = 1;
 312     *end   = 4; // 3 vector operands
 313     break;
 314   default:
 315     *start = 1;
 316     *end   = n->req(); // default is all operands
 317   }
 318 }
 319 
 320 // Return the vector version of a scalar operation node.
 321 VectorNode* VectorNode::make(int opc, Node* n1, Node* n2, uint vlen, BasicType bt) {
 322   const TypeVect* vt = TypeVect::make(bt, vlen);
 323   int vopc = VectorNode::opcode(opc, bt);
 324   // This method should not be called for unimplemented vectors.
 325   guarantee(vopc > 0, "Vector for '%s' is not implemented", NodeClassNames[opc]);
 326   switch (vopc) {
 327   case Op_AddVB: return new AddVBNode(n1, n2, vt);
 328   case Op_AddVS: return new AddVSNode(n1, n2, vt);
 329   case Op_AddVI: return new AddVINode(n1, n2, vt);
 330   case Op_AddVL: return new AddVLNode(n1, n2, vt);
 331   case Op_AddVF: return new AddVFNode(n1, n2, vt);
 332   case Op_AddVD: return new AddVDNode(n1, n2, vt);
 333 
 334   case Op_SubVB: return new SubVBNode(n1, n2, vt);
 335   case Op_SubVS: return new SubVSNode(n1, n2, vt);
 336   case Op_SubVI: return new SubVINode(n1, n2, vt);
 337   case Op_SubVL: return new SubVLNode(n1, n2, vt);
 338   case Op_SubVF: return new SubVFNode(n1, n2, vt);
 339   case Op_SubVD: return new SubVDNode(n1, n2, vt);
 340 
 341   case Op_MulVS: return new MulVSNode(n1, n2, vt);
 342   case Op_MulVI: return new MulVINode(n1, n2, vt);
 343   case Op_MulVL: return new MulVLNode(n1, n2, vt);
 344   case Op_MulVF: return new MulVFNode(n1, n2, vt);
 345   case Op_MulVD: return new MulVDNode(n1, n2, vt);
 346 
 347   case Op_DivVF: return new DivVFNode(n1, n2, vt);
 348   case Op_DivVD: return new DivVDNode(n1, n2, vt);
 349 
 350   case Op_AbsVF: return new AbsVFNode(n1, vt);
 351   case Op_AbsVD: return new AbsVDNode(n1, vt);
 352 
 353   case Op_NegVF: return new NegVFNode(n1, vt);
 354   case Op_NegVD: return new NegVDNode(n1, vt);
 355 
 356   case Op_SqrtVF: return new SqrtVFNode(n1, vt);
 357   case Op_SqrtVD: return new SqrtVDNode(n1, vt);
 358 
 359   case Op_PopCountVI: return new PopCountVINode(n1, vt);
 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 }
 400 
 401 // Scalar promotion
 402 VectorNode* VectorNode::scalar2vector(Node* s, uint vlen, const Type* opd_t) {
 403   BasicType bt = opd_t->array_element_basic_type();
 404   const TypeVect* vt = opd_t->singleton() ? TypeVect::make(opd_t, vlen)
 405                                           : TypeVect::make(bt, vlen);
 406   switch (bt) {
 407   case T_BOOLEAN:
 408   case T_BYTE:
 409     return new ReplicateBNode(s, vt);
 410   case T_CHAR:
 411   case T_SHORT:
 412     return new ReplicateSNode(s, vt);
 413   case T_INT:
 414     return new ReplicateINode(s, vt);
 415   case T_LONG:
 416     return new ReplicateLNode(s, vt);
 417   case T_FLOAT:
 418     return new ReplicateFNode(s, vt);
 419   case T_DOUBLE:
 420     return new ReplicateDNode(s, vt);
 421   default:
 422     fatal("Type '%s' is not supported for vectors", type2name(bt));
 423     return NULL;
 424   }
 425 }
 426 
 427 VectorNode* VectorNode::shift_count(Node* shift, Node* cnt, uint vlen, BasicType bt) {
 428   assert(VectorNode::is_shift(shift) && !cnt->is_Con(), "only variable shift count");
 429   // Match shift count type with shift vector type.
 430   const TypeVect* vt = TypeVect::make(bt, vlen);
 431   switch (shift->Opcode()) {
 432   case Op_LShiftI:
 433   case Op_LShiftL:
 434     return new LShiftCntVNode(cnt, vt);
 435   case Op_RShiftI:
 436   case Op_RShiftL:
 437   case Op_URShiftI:
 438   case Op_URShiftL:
 439     return new RShiftCntVNode(cnt, vt);
 440   default:
 441     fatal("Missed vector creation for '%s'", NodeClassNames[shift->Opcode()]);
 442     return NULL;
 443   }
 444 }
 445 
 446 // Return initial Pack node. Additional operands added with add_opd() calls.
 447 PackNode* PackNode::make(Node* s, uint vlen, BasicType bt) {
 448   const TypeVect* vt = TypeVect::make(bt, vlen);
 449   switch (bt) {
 450   case T_BOOLEAN:
 451   case T_BYTE:
 452     return new PackBNode(s, vt);
 453   case T_CHAR:
 454   case T_SHORT:
 455     return new PackSNode(s, vt);
 456   case T_INT:
 457     return new PackINode(s, vt);
 458   case T_LONG:
 459     return new PackLNode(s, vt);
 460   case T_FLOAT:
 461     return new PackFNode(s, vt);
 462   case T_DOUBLE:
 463     return new PackDNode(s, vt);
 464   default:
 465     fatal("Type '%s' is not supported for vectors", type2name(bt));
 466     return NULL;
 467   }
 468 }
 469 
 470 // Create a binary tree form for Packs. [lo, hi) (half-open) range
 471 PackNode* PackNode::binary_tree_pack(int lo, int hi) {
 472   int ct = hi - lo;
 473   assert(is_power_of_2(ct), "power of 2");
 474   if (ct == 2) {
 475     PackNode* pk = PackNode::make(in(lo), 2, vect_type()->element_basic_type());
 476     pk->add_opd(in(lo+1));
 477     return pk;
 478   } else {
 479     int mid = lo + ct/2;
 480     PackNode* n1 = binary_tree_pack(lo,  mid);
 481     PackNode* n2 = binary_tree_pack(mid, hi );
 482 
 483     BasicType bt = n1->vect_type()->element_basic_type();
 484     assert(bt == n2->vect_type()->element_basic_type(), "should be the same");
 485     switch (bt) {
 486     case T_BOOLEAN:
 487     case T_BYTE:
 488       return new PackSNode(n1, n2, TypeVect::make(T_SHORT, 2));
 489     case T_CHAR:
 490     case T_SHORT:
 491       return new PackINode(n1, n2, TypeVect::make(T_INT, 2));
 492     case T_INT:
 493       return new PackLNode(n1, n2, TypeVect::make(T_LONG, 2));
 494     case T_LONG:
 495       return new Pack2LNode(n1, n2, TypeVect::make(T_LONG, 2));
 496     case T_FLOAT:
 497       return new PackDNode(n1, n2, TypeVect::make(T_DOUBLE, 2));
 498     case T_DOUBLE:
 499       return new Pack2DNode(n1, n2, TypeVect::make(T_DOUBLE, 2));
 500     default:
 501       fatal("Type '%s' is not supported for vectors", type2name(bt));
 502       return NULL;
 503     }
 504   }
 505 }
 506 
 507 // Return the vector version of a scalar load node.
 508 LoadVectorNode* LoadVectorNode::make(int opc, Node* ctl, Node* mem,
 509                                      Node* adr, const TypePtr* atyp,
 510                                      uint vlen, BasicType bt,
 511                                      ControlDependency control_dependency) {
 512   const TypeVect* vt = TypeVect::make(bt, vlen);
 513   return new LoadVectorNode(ctl, mem, adr, atyp, vt, control_dependency);
 514 }
 515 
 516 // Return the vector version of a scalar store node.
 517 StoreVectorNode* StoreVectorNode::make(int opc, Node* ctl, Node* mem,
 518                                        Node* adr, const TypePtr* atyp, Node* val,
 519                                        uint vlen) {
 520   return new StoreVectorNode(ctl, mem, adr, atyp, val);
 521 }
 522 
 523 // Extract a scalar element of vector.
 524 Node* ExtractNode::make(Node* v, uint position, BasicType bt) {
 525   assert((int)position < Matcher::max_vector_size(bt), "pos in range");
 526   ConINode* pos = ConINode::make((int)position);
 527   switch (bt) {
 528   case T_BOOLEAN:
 529     return new ExtractUBNode(v, pos);
 530   case T_BYTE:
 531     return new ExtractBNode(v, pos);
 532   case T_CHAR:
 533     return new ExtractCNode(v, pos);
 534   case T_SHORT:
 535     return new ExtractSNode(v, pos);
 536   case T_INT:
 537     return new ExtractINode(v, pos);
 538   case T_LONG:
 539     return new ExtractLNode(v, pos);
 540   case T_FLOAT:
 541     return new ExtractFNode(v, pos);
 542   case T_DOUBLE:
 543     return new ExtractDNode(v, pos);
 544   default:
 545     fatal("Type '%s' is not supported for vectors", type2name(bt));
 546     return NULL;
 547   }
 548 }
 549 
 550 int ReductionNode::opcode(int opc, BasicType bt) {
 551   int vopc = opc;
 552   switch (opc) {
 553     case Op_AddI:
 554       assert(bt == T_INT, "must be");
 555       vopc = Op_AddReductionVI;
 556       break;
 557     case Op_AddL:
 558       assert(bt == T_LONG, "must be");
 559       vopc = Op_AddReductionVL;
 560       break;
 561     case Op_AddF:
 562       assert(bt == T_FLOAT, "must be");
 563       vopc = Op_AddReductionVF;
 564       break;
 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 }