< prev index next >

src/hotspot/share/opto/vectornode.cpp

Print this page

 349   return is_shift_opcode(n->Opcode());
 350 }
 351 
 352 bool VectorNode::is_rotate_opcode(int opc) {
 353   switch (opc) {
 354   case Op_RotateRight:
 355   case Op_RotateLeft:
 356     return true;
 357   default:
 358     return false;
 359   }
 360 }
 361 
 362 bool VectorNode::is_scalar_rotate(Node* n) {
 363   if (is_rotate_opcode(n->Opcode())) {
 364     return true;
 365   }
 366   return false;
 367 }
 368 
 369 bool VectorNode::is_vshift_cnt(Node* n) {
 370   switch (n->Opcode()) {
 371   case Op_LShiftCntV:
 372   case Op_RShiftCntV:
 373     return true;
 374   default:
 375     return false;
 376   }
 377 }
 378 




 379 // Check if input is loop invariant vector.
 380 bool VectorNode::is_invariant_vector(Node* n) {
 381   // Only Replicate vector nodes are loop invariant for now.
 382   switch (n->Opcode()) {
 383   case Op_ReplicateB:
 384   case Op_ReplicateS:
 385   case Op_ReplicateI:
 386   case Op_ReplicateL:
 387   case Op_ReplicateF:
 388   case Op_ReplicateD:
 389     return true;
 390   default:
 391     return false;
 392   }
 393 }
 394 
 395 // [Start, end) half-open range defining which operands are vectors
 396 void VectorNode::vector_operands(Node* n, uint* start, uint* end) {
 397   switch (n->Opcode()) {
 398   case Op_LoadB:   case Op_LoadUB:

 425   case Op_XorI: case Op_XorL:
 426   case Op_MulAddS2I:
 427     *start = 1;
 428     *end   = 3; // 2 vector operands
 429     break;
 430   case Op_CMoveI:  case Op_CMoveL:  case Op_CMoveF:  case Op_CMoveD:
 431     *start = 2;
 432     *end   = n->req();
 433     break;
 434   case Op_FmaD:
 435   case Op_FmaF:
 436     *start = 1;
 437     *end   = 4; // 3 vector operands
 438     break;
 439   default:
 440     *start = 1;
 441     *end   = n->req(); // default is all operands
 442   }
 443 }
 444 

























 445 // Make a vector node for binary operation
 446 VectorNode* VectorNode::make(int vopc, Node* n1, Node* n2, const TypeVect* vt) {
 447   // This method should not be called for unimplemented vectors.
 448   guarantee(vopc > 0, "vopc must be > 0");





 449   switch (vopc) {
 450   case Op_AddVB: return new AddVBNode(n1, n2, vt);
 451   case Op_AddVS: return new AddVSNode(n1, n2, vt);
 452   case Op_AddVI: return new AddVINode(n1, n2, vt);
 453   case Op_AddVL: return new AddVLNode(n1, n2, vt);
 454   case Op_AddVF: return new AddVFNode(n1, n2, vt);
 455   case Op_AddVD: return new AddVDNode(n1, n2, vt);
 456 
 457   case Op_SubVB: return new SubVBNode(n1, n2, vt);
 458   case Op_SubVS: return new SubVSNode(n1, n2, vt);
 459   case Op_SubVI: return new SubVINode(n1, n2, vt);
 460   case Op_SubVL: return new SubVLNode(n1, n2, vt);
 461   case Op_SubVF: return new SubVFNode(n1, n2, vt);
 462   case Op_SubVD: return new SubVDNode(n1, n2, vt);
 463 
 464   case Op_MulVB: return new MulVBNode(n1, n2, vt);
 465   case Op_MulVS: return new MulVSNode(n1, n2, vt);
 466   case Op_MulVI: return new MulVINode(n1, n2, vt);
 467   case Op_MulVL: return new MulVLNode(n1, n2, vt);
 468   case Op_MulVF: return new MulVFNode(n1, n2, vt);

 535   guarantee(vopc > 0, "vopc must be > 0");
 536   switch (vopc) {
 537   case Op_FmaVD: return new FmaVDNode(n1, n2, n3, vt);
 538   case Op_FmaVF: return new FmaVFNode(n1, n2, n3, vt);
 539   default:
 540     fatal("Missed vector creation for '%s'", NodeClassNames[vopc]);
 541     return NULL;
 542   }
 543 }
 544 
 545 // Return the vector version of a scalar ternary operation node.
 546 VectorNode* VectorNode::make(int opc, Node* n1, Node* n2, Node* n3, uint vlen, BasicType bt) {
 547   const TypeVect* vt = TypeVect::make(bt, vlen);
 548   int vopc = VectorNode::opcode(opc, bt);
 549   // This method should not be called for unimplemented vectors.
 550   guarantee(vopc > 0, "Vector for '%s' is not implemented", NodeClassNames[opc]);
 551   return make(vopc, n1, n2, n3, vt);
 552 }
 553 
 554 // Scalar promotion
 555 VectorNode* VectorNode::scalar2vector(Node* s, uint vlen, const Type* opd_t) {
 556   BasicType bt = opd_t->array_element_basic_type();
 557   const TypeVect* vt = opd_t->singleton() ? TypeVect::make(opd_t, vlen)
 558                                           : TypeVect::make(bt, vlen);





 559   switch (bt) {
 560   case T_BOOLEAN:
 561   case T_BYTE:
 562     return new ReplicateBNode(s, vt);
 563   case T_CHAR:
 564   case T_SHORT:
 565     return new ReplicateSNode(s, vt);
 566   case T_INT:
 567     return new ReplicateINode(s, vt);
 568   case T_LONG:
 569     return new ReplicateLNode(s, vt);
 570   case T_FLOAT:
 571     return new ReplicateFNode(s, vt);
 572   case T_DOUBLE:
 573     return new ReplicateDNode(s, vt);
 574   default:
 575     fatal("Type '%s' is not supported for vectors", type2name(bt));
 576     return NULL;
 577   }
 578 }

 989   case Op_AddReductionVL: return new AddReductionVLNode(ctrl, n1, n2);
 990   case Op_AddReductionVF: return new AddReductionVFNode(ctrl, n1, n2);
 991   case Op_AddReductionVD: return new AddReductionVDNode(ctrl, n1, n2);
 992   case Op_MulReductionVI: return new MulReductionVINode(ctrl, n1, n2);
 993   case Op_MulReductionVL: return new MulReductionVLNode(ctrl, n1, n2);
 994   case Op_MulReductionVF: return new MulReductionVFNode(ctrl, n1, n2);
 995   case Op_MulReductionVD: return new MulReductionVDNode(ctrl, n1, n2);
 996   case Op_MinReductionV:  return new MinReductionVNode(ctrl, n1, n2);
 997   case Op_MaxReductionV:  return new MaxReductionVNode(ctrl, n1, n2);
 998   case Op_AndReductionV:  return new AndReductionVNode(ctrl, n1, n2);
 999   case Op_OrReductionV:   return new OrReductionVNode(ctrl, n1, n2);
1000   case Op_XorReductionV:  return new XorReductionVNode(ctrl, n1, n2);
1001   default:
1002     assert(false, "unknown node: %s", NodeClassNames[vopc]);
1003     return NULL;
1004   }
1005 }
1006 
1007 Node* VectorLoadMaskNode::Identity(PhaseGVN* phase) {
1008   BasicType out_bt = type()->is_vect()->element_basic_type();
1009   if (out_bt == T_BOOLEAN) {
1010     return in(1); // redundant conversion
1011   }

1012   return this;
1013 }
1014 
1015 Node* VectorStoreMaskNode::Identity(PhaseGVN* phase) {
1016   // Identity transformation on boolean vectors.
1017   //   VectorStoreMask (VectorLoadMask bv) elem_size ==> bv
1018   //   vector[n]{bool} => vector[n]{t} => vector[n]{bool}
1019   if (in(1)->Opcode() == Op_VectorLoadMask) {
1020     return in(1)->in(1);
1021   }
1022   return this;
1023 }
1024 
1025 VectorStoreMaskNode* VectorStoreMaskNode::make(PhaseGVN& gvn, Node* in, BasicType in_type, uint num_elem) {
1026   assert(in->bottom_type()->isa_vect(), "sanity");
1027   const TypeVect* vt = TypeVect::make(T_BOOLEAN, num_elem);
1028   int elem_size = type2aelembytes(in_type);
1029   return new VectorStoreMaskNode(in, gvn.intcon(elem_size), vt);
1030 }
1031 

1088       }
1089       break;
1090     case Op_AddReductionVI: // fallthrough
1091     case Op_AddReductionVL: // fallthrough
1092     case Op_AddReductionVF: // fallthrough
1093     case Op_AddReductionVD:
1094     case Op_OrReductionV:
1095     case Op_XorReductionV:
1096       return gvn.zerocon(bt);
1097     case Op_MulReductionVI:
1098       return gvn.makecon(TypeInt::ONE);
1099     case Op_MulReductionVL:
1100       return gvn.makecon(TypeLong::ONE);
1101     case Op_MulReductionVF:
1102       return gvn.makecon(TypeF::ONE);
1103     case Op_MulReductionVD:
1104       return gvn.makecon(TypeD::ONE);
1105     case Op_MinReductionV:
1106       switch (bt) {
1107         case T_BYTE:

1108         case T_SHORT:

1109         case T_INT:
1110           return gvn.makecon(TypeInt::MAX);
1111         case T_LONG:
1112           return gvn.makecon(TypeLong::MAX);
1113         case T_FLOAT:
1114           return gvn.makecon(TypeF::POS_INF);
1115         case T_DOUBLE:
1116           return gvn.makecon(TypeD::POS_INF);
1117           default: Unimplemented(); return NULL;
1118       }
1119       break;
1120     case Op_MaxReductionV:
1121       switch (bt) {
1122         case T_BYTE:

1123         case T_SHORT:

1124         case T_INT:
1125           return gvn.makecon(TypeInt::MIN);
1126         case T_LONG:
1127           return gvn.makecon(TypeLong::MIN);
1128         case T_FLOAT:
1129           return gvn.makecon(TypeF::NEG_INF);
1130         case T_DOUBLE:
1131           return gvn.makecon(TypeD::NEG_INF);
1132           default: Unimplemented(); return NULL;
1133       }
1134       break;
1135     default:
1136       fatal("Missed vector creation for '%s'", NodeClassNames[vopc]);
1137       return NULL;
1138   }
1139 }
1140 
1141 bool ReductionNode::implemented(int opc, uint vlen, BasicType bt) {
1142   if (is_java_primitive(bt) &&
1143       (vlen > 1) && is_power_of_2(vlen) &&

1296   return new VectorInsertNode(vec, new_val, pos, vec->bottom_type()->is_vect());
1297 }
1298 
1299 Node* VectorUnboxNode::Ideal(PhaseGVN* phase, bool can_reshape) {
1300   Node* n = obj()->uncast();
1301   if (EnableVectorReboxing && n->Opcode() == Op_VectorBox) {
1302     if (Type::cmp(bottom_type(), n->in(VectorBoxNode::Value)->bottom_type()) == 0) {
1303       // Handled by VectorUnboxNode::Identity()
1304     } else {
1305       VectorBoxNode* vbox = static_cast<VectorBoxNode*>(n);
1306       ciKlass* vbox_klass = vbox->box_type()->klass();
1307       const TypeVect* in_vt = vbox->vec_type();
1308       const TypeVect* out_vt = type()->is_vect();
1309 
1310       if (in_vt->length() == out_vt->length()) {
1311         Node* value = vbox->in(VectorBoxNode::Value);
1312 
1313         bool is_vector_mask    = vbox_klass->is_subclass_of(ciEnv::current()->vector_VectorMask_klass());
1314         bool is_vector_shuffle = vbox_klass->is_subclass_of(ciEnv::current()->vector_VectorShuffle_klass());
1315         if (is_vector_mask) {

1316           if (in_vt->length_in_bytes() == out_vt->length_in_bytes() &&
1317               Matcher::match_rule_supported_vector(Op_VectorMaskCast, out_vt->length(), out_vt->element_basic_type())) {
1318             // Apply "VectorUnbox (VectorBox vmask) ==> VectorMaskCast (vmask)"
1319             // directly. This could avoid the transformation ordering issue from
1320             // "VectorStoreMask (VectorLoadMask vmask) => vmask".
1321             return new VectorMaskCastNode(value, out_vt);
1322           }
1323           // VectorUnbox (VectorBox vmask) ==> VectorLoadMask (VectorStoreMask vmask)
1324           value = phase->transform(VectorStoreMaskNode::make(*phase, value, in_vt->element_basic_type(), in_vt->length()));
1325           return new VectorLoadMaskNode(value, out_vt);
1326         } else if (is_vector_shuffle) {
1327           if (!is_shuffle_to_vector()) {
1328             // VectorUnbox (VectorBox vshuffle) ==> VectorLoadShuffle vshuffle
1329             return new VectorLoadShuffleNode(value, out_vt);
1330           }
1331         } else {
1332           // Vector type mismatch is only supported for masks and shuffles, but sometimes it happens in pathological cases.
1333         }
1334       } else {
1335         // Vector length mismatch.
1336         // Sometimes happen in pathological cases (e.g., when unboxing happens in effectively dead code).
1337       }
1338     }
1339   }
1340   return NULL;
1341 }
1342 
1343 Node* VectorUnboxNode::Identity(PhaseGVN* phase) {
1344   Node* n = obj()->uncast();
1345   if (EnableVectorReboxing && n->Opcode() == Op_VectorBox) {

1363   return TypeFunc::make(domain, range);
1364 }
1365 
1366 Node* ShiftVNode::Identity(PhaseGVN* phase) {
1367   Node* in2 = in(2);
1368   // Shift by ZERO does nothing
1369   if (is_vshift_cnt(in2) && phase->find_int_type(in2->in(1)) == TypeInt::ZERO) {
1370     return in(1);
1371   }
1372   return this;
1373 }
1374 
1375 Node* VectorMaskOpNode::make(Node* mask, const Type* ty, int mopc) {
1376   switch(mopc) {
1377     case Op_VectorMaskTrueCount:
1378       return new VectorMaskTrueCountNode(mask, ty);
1379     case Op_VectorMaskLastTrue:
1380       return new VectorMaskLastTrueNode(mask, ty);
1381     case Op_VectorMaskFirstTrue:
1382       return new VectorMaskFirstTrueNode(mask, ty);


1383     default:
1384       assert(false, "Unhandled operation");
1385   }
1386   return NULL;
1387 }
1388 
1389 
1390 #ifndef PRODUCT
1391 void VectorBoxAllocateNode::dump_spec(outputStream *st) const {
1392   CallStaticJavaNode::dump_spec(st);
1393 }
1394 
1395 #endif // !PRODUCT

 349   return is_shift_opcode(n->Opcode());
 350 }
 351 
 352 bool VectorNode::is_rotate_opcode(int opc) {
 353   switch (opc) {
 354   case Op_RotateRight:
 355   case Op_RotateLeft:
 356     return true;
 357   default:
 358     return false;
 359   }
 360 }
 361 
 362 bool VectorNode::is_scalar_rotate(Node* n) {
 363   if (is_rotate_opcode(n->Opcode())) {
 364     return true;
 365   }
 366   return false;
 367 }
 368 
 369 bool VectorNode::is_vshift_cnt_opcode(int opc) {
 370   switch (opc) {
 371   case Op_LShiftCntV:
 372   case Op_RShiftCntV:
 373     return true;
 374   default:
 375     return false;
 376   }
 377 }
 378 
 379 bool VectorNode::is_vshift_cnt(Node* n) {
 380   return is_vshift_cnt_opcode(n->Opcode());
 381 }
 382 
 383 // Check if input is loop invariant vector.
 384 bool VectorNode::is_invariant_vector(Node* n) {
 385   // Only Replicate vector nodes are loop invariant for now.
 386   switch (n->Opcode()) {
 387   case Op_ReplicateB:
 388   case Op_ReplicateS:
 389   case Op_ReplicateI:
 390   case Op_ReplicateL:
 391   case Op_ReplicateF:
 392   case Op_ReplicateD:
 393     return true;
 394   default:
 395     return false;
 396   }
 397 }
 398 
 399 // [Start, end) half-open range defining which operands are vectors
 400 void VectorNode::vector_operands(Node* n, uint* start, uint* end) {
 401   switch (n->Opcode()) {
 402   case Op_LoadB:   case Op_LoadUB:

 429   case Op_XorI: case Op_XorL:
 430   case Op_MulAddS2I:
 431     *start = 1;
 432     *end   = 3; // 2 vector operands
 433     break;
 434   case Op_CMoveI:  case Op_CMoveL:  case Op_CMoveF:  case Op_CMoveD:
 435     *start = 2;
 436     *end   = n->req();
 437     break;
 438   case Op_FmaD:
 439   case Op_FmaF:
 440     *start = 1;
 441     *end   = 4; // 3 vector operands
 442     break;
 443   default:
 444     *start = 1;
 445     *end   = n->req(); // default is all operands
 446   }
 447 }
 448 
 449 VectorNode* VectorNode::make_mask_node(int vopc, Node* n1, Node* n2, uint vlen, BasicType bt) {
 450   guarantee(vopc > 0, "vopc must be > 0");
 451   const TypeVect* vmask_type = TypeVect::makemask(bt, vlen);
 452   switch (vopc) {
 453     case Op_AndV:
 454       if (Matcher::match_rule_supported_vector_masked(Op_AndVMask, vlen, bt)) {
 455         return new AndVMaskNode(n1, n2, vmask_type);
 456       }
 457       return new AndVNode(n1, n2, vmask_type);
 458     case Op_OrV:
 459       if (Matcher::match_rule_supported_vector_masked(Op_OrVMask, vlen, bt)) {
 460         return new OrVMaskNode(n1, n2, vmask_type);
 461       }
 462       return new OrVNode(n1, n2, vmask_type);
 463     case Op_XorV:
 464       if (Matcher::match_rule_supported_vector_masked(Op_XorVMask, vlen, bt)) {
 465         return new XorVMaskNode(n1, n2, vmask_type);
 466       }
 467       return new XorVNode(n1, n2, vmask_type);
 468     default:
 469       fatal("Unsupported mask vector creation for '%s'", NodeClassNames[vopc]);
 470       return NULL;
 471   }
 472 }
 473 
 474 // Make a vector node for binary operation
 475 VectorNode* VectorNode::make(int vopc, Node* n1, Node* n2, const TypeVect* vt, bool is_mask) {
 476   // This method should not be called for unimplemented vectors.
 477   guarantee(vopc > 0, "vopc must be > 0");
 478 
 479   if (is_mask) {
 480     return make_mask_node(vopc, n1, n2, vt->length(), vt->element_basic_type());
 481   }
 482 
 483   switch (vopc) {
 484   case Op_AddVB: return new AddVBNode(n1, n2, vt);
 485   case Op_AddVS: return new AddVSNode(n1, n2, vt);
 486   case Op_AddVI: return new AddVINode(n1, n2, vt);
 487   case Op_AddVL: return new AddVLNode(n1, n2, vt);
 488   case Op_AddVF: return new AddVFNode(n1, n2, vt);
 489   case Op_AddVD: return new AddVDNode(n1, n2, vt);
 490 
 491   case Op_SubVB: return new SubVBNode(n1, n2, vt);
 492   case Op_SubVS: return new SubVSNode(n1, n2, vt);
 493   case Op_SubVI: return new SubVINode(n1, n2, vt);
 494   case Op_SubVL: return new SubVLNode(n1, n2, vt);
 495   case Op_SubVF: return new SubVFNode(n1, n2, vt);
 496   case Op_SubVD: return new SubVDNode(n1, n2, vt);
 497 
 498   case Op_MulVB: return new MulVBNode(n1, n2, vt);
 499   case Op_MulVS: return new MulVSNode(n1, n2, vt);
 500   case Op_MulVI: return new MulVINode(n1, n2, vt);
 501   case Op_MulVL: return new MulVLNode(n1, n2, vt);
 502   case Op_MulVF: return new MulVFNode(n1, n2, vt);

 569   guarantee(vopc > 0, "vopc must be > 0");
 570   switch (vopc) {
 571   case Op_FmaVD: return new FmaVDNode(n1, n2, n3, vt);
 572   case Op_FmaVF: return new FmaVFNode(n1, n2, n3, vt);
 573   default:
 574     fatal("Missed vector creation for '%s'", NodeClassNames[vopc]);
 575     return NULL;
 576   }
 577 }
 578 
 579 // Return the vector version of a scalar ternary operation node.
 580 VectorNode* VectorNode::make(int opc, Node* n1, Node* n2, Node* n3, uint vlen, BasicType bt) {
 581   const TypeVect* vt = TypeVect::make(bt, vlen);
 582   int vopc = VectorNode::opcode(opc, bt);
 583   // This method should not be called for unimplemented vectors.
 584   guarantee(vopc > 0, "Vector for '%s' is not implemented", NodeClassNames[opc]);
 585   return make(vopc, n1, n2, n3, vt);
 586 }
 587 
 588 // Scalar promotion
 589 VectorNode* VectorNode::scalar2vector(Node* s, uint vlen, const Type* opd_t, bool is_mask) {
 590   BasicType bt = opd_t->array_element_basic_type();
 591   const TypeVect* vt = opd_t->singleton() ? TypeVect::make(opd_t, vlen, is_mask)
 592                                           : TypeVect::make(bt, vlen, is_mask);
 593 
 594   if (is_mask && Matcher::match_rule_supported_vector(Op_MaskAll, vlen, bt)) {
 595     return new MaskAllNode(s, vt);
 596   }
 597 
 598   switch (bt) {
 599   case T_BOOLEAN:
 600   case T_BYTE:
 601     return new ReplicateBNode(s, vt);
 602   case T_CHAR:
 603   case T_SHORT:
 604     return new ReplicateSNode(s, vt);
 605   case T_INT:
 606     return new ReplicateINode(s, vt);
 607   case T_LONG:
 608     return new ReplicateLNode(s, vt);
 609   case T_FLOAT:
 610     return new ReplicateFNode(s, vt);
 611   case T_DOUBLE:
 612     return new ReplicateDNode(s, vt);
 613   default:
 614     fatal("Type '%s' is not supported for vectors", type2name(bt));
 615     return NULL;
 616   }
 617 }

1028   case Op_AddReductionVL: return new AddReductionVLNode(ctrl, n1, n2);
1029   case Op_AddReductionVF: return new AddReductionVFNode(ctrl, n1, n2);
1030   case Op_AddReductionVD: return new AddReductionVDNode(ctrl, n1, n2);
1031   case Op_MulReductionVI: return new MulReductionVINode(ctrl, n1, n2);
1032   case Op_MulReductionVL: return new MulReductionVLNode(ctrl, n1, n2);
1033   case Op_MulReductionVF: return new MulReductionVFNode(ctrl, n1, n2);
1034   case Op_MulReductionVD: return new MulReductionVDNode(ctrl, n1, n2);
1035   case Op_MinReductionV:  return new MinReductionVNode(ctrl, n1, n2);
1036   case Op_MaxReductionV:  return new MaxReductionVNode(ctrl, n1, n2);
1037   case Op_AndReductionV:  return new AndReductionVNode(ctrl, n1, n2);
1038   case Op_OrReductionV:   return new OrReductionVNode(ctrl, n1, n2);
1039   case Op_XorReductionV:  return new XorReductionVNode(ctrl, n1, n2);
1040   default:
1041     assert(false, "unknown node: %s", NodeClassNames[vopc]);
1042     return NULL;
1043   }
1044 }
1045 
1046 Node* VectorLoadMaskNode::Identity(PhaseGVN* phase) {
1047   BasicType out_bt = type()->is_vect()->element_basic_type();
1048   if (!Matcher::has_predicated_vectors() && out_bt == T_BOOLEAN) {
1049     return in(1); // redundant conversion
1050   }
1051 
1052   return this;
1053 }
1054 
1055 Node* VectorStoreMaskNode::Identity(PhaseGVN* phase) {
1056   // Identity transformation on boolean vectors.
1057   //   VectorStoreMask (VectorLoadMask bv) elem_size ==> bv
1058   //   vector[n]{bool} => vector[n]{t} => vector[n]{bool}
1059   if (in(1)->Opcode() == Op_VectorLoadMask) {
1060     return in(1)->in(1);
1061   }
1062   return this;
1063 }
1064 
1065 VectorStoreMaskNode* VectorStoreMaskNode::make(PhaseGVN& gvn, Node* in, BasicType in_type, uint num_elem) {
1066   assert(in->bottom_type()->isa_vect(), "sanity");
1067   const TypeVect* vt = TypeVect::make(T_BOOLEAN, num_elem);
1068   int elem_size = type2aelembytes(in_type);
1069   return new VectorStoreMaskNode(in, gvn.intcon(elem_size), vt);
1070 }
1071 

1128       }
1129       break;
1130     case Op_AddReductionVI: // fallthrough
1131     case Op_AddReductionVL: // fallthrough
1132     case Op_AddReductionVF: // fallthrough
1133     case Op_AddReductionVD:
1134     case Op_OrReductionV:
1135     case Op_XorReductionV:
1136       return gvn.zerocon(bt);
1137     case Op_MulReductionVI:
1138       return gvn.makecon(TypeInt::ONE);
1139     case Op_MulReductionVL:
1140       return gvn.makecon(TypeLong::ONE);
1141     case Op_MulReductionVF:
1142       return gvn.makecon(TypeF::ONE);
1143     case Op_MulReductionVD:
1144       return gvn.makecon(TypeD::ONE);
1145     case Op_MinReductionV:
1146       switch (bt) {
1147         case T_BYTE:
1148           return gvn.makecon(TypeInt::make(max_jbyte));
1149         case T_SHORT:
1150           return gvn.makecon(TypeInt::make(max_jshort));
1151         case T_INT:
1152           return gvn.makecon(TypeInt::MAX);
1153         case T_LONG:
1154           return gvn.makecon(TypeLong::MAX);
1155         case T_FLOAT:
1156           return gvn.makecon(TypeF::POS_INF);
1157         case T_DOUBLE:
1158           return gvn.makecon(TypeD::POS_INF);
1159           default: Unimplemented(); return NULL;
1160       }
1161       break;
1162     case Op_MaxReductionV:
1163       switch (bt) {
1164         case T_BYTE:
1165           return gvn.makecon(TypeInt::make(min_jbyte));
1166         case T_SHORT:
1167           return gvn.makecon(TypeInt::make(min_jshort));
1168         case T_INT:
1169           return gvn.makecon(TypeInt::MIN);
1170         case T_LONG:
1171           return gvn.makecon(TypeLong::MIN);
1172         case T_FLOAT:
1173           return gvn.makecon(TypeF::NEG_INF);
1174         case T_DOUBLE:
1175           return gvn.makecon(TypeD::NEG_INF);
1176           default: Unimplemented(); return NULL;
1177       }
1178       break;
1179     default:
1180       fatal("Missed vector creation for '%s'", NodeClassNames[vopc]);
1181       return NULL;
1182   }
1183 }
1184 
1185 bool ReductionNode::implemented(int opc, uint vlen, BasicType bt) {
1186   if (is_java_primitive(bt) &&
1187       (vlen > 1) && is_power_of_2(vlen) &&

1340   return new VectorInsertNode(vec, new_val, pos, vec->bottom_type()->is_vect());
1341 }
1342 
1343 Node* VectorUnboxNode::Ideal(PhaseGVN* phase, bool can_reshape) {
1344   Node* n = obj()->uncast();
1345   if (EnableVectorReboxing && n->Opcode() == Op_VectorBox) {
1346     if (Type::cmp(bottom_type(), n->in(VectorBoxNode::Value)->bottom_type()) == 0) {
1347       // Handled by VectorUnboxNode::Identity()
1348     } else {
1349       VectorBoxNode* vbox = static_cast<VectorBoxNode*>(n);
1350       ciKlass* vbox_klass = vbox->box_type()->klass();
1351       const TypeVect* in_vt = vbox->vec_type();
1352       const TypeVect* out_vt = type()->is_vect();
1353 
1354       if (in_vt->length() == out_vt->length()) {
1355         Node* value = vbox->in(VectorBoxNode::Value);
1356 
1357         bool is_vector_mask    = vbox_klass->is_subclass_of(ciEnv::current()->vector_VectorMask_klass());
1358         bool is_vector_shuffle = vbox_klass->is_subclass_of(ciEnv::current()->vector_VectorShuffle_klass());
1359         if (is_vector_mask) {
1360           const TypeVect* vmask_type = TypeVect::makemask(out_vt->element_basic_type(), out_vt->length());
1361           if (in_vt->length_in_bytes() == out_vt->length_in_bytes() &&
1362               Matcher::match_rule_supported_vector(Op_VectorMaskCast, out_vt->length(), out_vt->element_basic_type())) {
1363             // Apply "VectorUnbox (VectorBox vmask) ==> VectorMaskCast (vmask)"
1364             // directly. This could avoid the transformation ordering issue from
1365             // "VectorStoreMask (VectorLoadMask vmask) => vmask".
1366             return new VectorMaskCastNode(value, vmask_type);
1367           }
1368           // VectorUnbox (VectorBox vmask) ==> VectorLoadMask (VectorStoreMask vmask)
1369           value = phase->transform(VectorStoreMaskNode::make(*phase, value, in_vt->element_basic_type(), in_vt->length()));
1370           return new VectorLoadMaskNode(value, vmask_type);
1371         } else if (is_vector_shuffle) {
1372           if (!is_shuffle_to_vector()) {
1373             // VectorUnbox (VectorBox vshuffle) ==> VectorLoadShuffle vshuffle
1374             return new VectorLoadShuffleNode(value, out_vt);
1375           }
1376         } else {
1377           // Vector type mismatch is only supported for masks and shuffles, but sometimes it happens in pathological cases.
1378         }
1379       } else {
1380         // Vector length mismatch.
1381         // Sometimes happen in pathological cases (e.g., when unboxing happens in effectively dead code).
1382       }
1383     }
1384   }
1385   return NULL;
1386 }
1387 
1388 Node* VectorUnboxNode::Identity(PhaseGVN* phase) {
1389   Node* n = obj()->uncast();
1390   if (EnableVectorReboxing && n->Opcode() == Op_VectorBox) {

1408   return TypeFunc::make(domain, range);
1409 }
1410 
1411 Node* ShiftVNode::Identity(PhaseGVN* phase) {
1412   Node* in2 = in(2);
1413   // Shift by ZERO does nothing
1414   if (is_vshift_cnt(in2) && phase->find_int_type(in2->in(1)) == TypeInt::ZERO) {
1415     return in(1);
1416   }
1417   return this;
1418 }
1419 
1420 Node* VectorMaskOpNode::make(Node* mask, const Type* ty, int mopc) {
1421   switch(mopc) {
1422     case Op_VectorMaskTrueCount:
1423       return new VectorMaskTrueCountNode(mask, ty);
1424     case Op_VectorMaskLastTrue:
1425       return new VectorMaskLastTrueNode(mask, ty);
1426     case Op_VectorMaskFirstTrue:
1427       return new VectorMaskFirstTrueNode(mask, ty);
1428     case Op_VectorMaskToLong:
1429       return new VectorMaskToLongNode(mask, ty);
1430     default:
1431       assert(false, "Unhandled operation");
1432   }
1433   return NULL;
1434 }
1435 

1436 #ifndef PRODUCT
1437 void VectorBoxAllocateNode::dump_spec(outputStream *st) const {
1438   CallStaticJavaNode::dump_spec(st);
1439 }
1440 
1441 #endif // !PRODUCT
< prev index next >