src/share/vm/opto/vectornode.cpp

changeset 4006
5af51c882207
parent 4004
4b0d6fd74911
child 4115
e626685e9f6c
     1.1 --- a/src/share/vm/opto/vectornode.cpp	Wed Aug 22 14:29:57 2012 +0200
     1.2 +++ b/src/share/vm/opto/vectornode.cpp	Wed Aug 22 11:55:40 2012 -0700
     1.3 @@ -31,7 +31,7 @@
     1.4  // Return the vector operator for the specified scalar operation
     1.5  // and vector length.  Also used to check if the code generator
     1.6  // supports the vector operation.
     1.7 -int VectorNode::opcode(int sopc, uint vlen, BasicType bt) {
     1.8 +int VectorNode::opcode(int sopc, BasicType bt) {
     1.9    switch (sopc) {
    1.10    case Op_AddI:
    1.11      switch (bt) {
    1.12 @@ -161,7 +161,7 @@
    1.13    if (is_java_primitive(bt) &&
    1.14        (vlen > 1) && is_power_of_2(vlen) &&
    1.15        Matcher::vector_size_supported(bt, vlen)) {
    1.16 -    int vopc = VectorNode::opcode(opc, vlen, bt);
    1.17 +    int vopc = VectorNode::opcode(opc, bt);
    1.18      return vopc > 0 && Matcher::has_match_rule(vopc);
    1.19    }
    1.20    return false;
    1.21 @@ -195,10 +195,54 @@
    1.22    return false;
    1.23  }
    1.24  
    1.25 +// [Start, end) half-open range defining which operands are vectors
    1.26 +void VectorNode::vector_operands(Node* n, uint* start, uint* end) {
    1.27 +  switch (n->Opcode()) {
    1.28 +  case Op_LoadB:   case Op_LoadUB:
    1.29 +  case Op_LoadS:   case Op_LoadUS:
    1.30 +  case Op_LoadI:   case Op_LoadL:
    1.31 +  case Op_LoadF:   case Op_LoadD:
    1.32 +  case Op_LoadP:   case Op_LoadN:
    1.33 +    *start = 0;
    1.34 +    *end   = 0; // no vector operands
    1.35 +    break;
    1.36 +  case Op_StoreB:  case Op_StoreC:
    1.37 +  case Op_StoreI:  case Op_StoreL:
    1.38 +  case Op_StoreF:  case Op_StoreD:
    1.39 +  case Op_StoreP:  case Op_StoreN:
    1.40 +    *start = MemNode::ValueIn;
    1.41 +    *end   = MemNode::ValueIn + 1; // 1 vector operand
    1.42 +    break;
    1.43 +  case Op_LShiftI:  case Op_LShiftL:
    1.44 +  case Op_RShiftI:  case Op_RShiftL:
    1.45 +  case Op_URShiftI: case Op_URShiftL:
    1.46 +    *start = 1;
    1.47 +    *end   = 2; // 1 vector operand
    1.48 +    break;
    1.49 +  case Op_AddI: case Op_AddL: case Op_AddF: case Op_AddD:
    1.50 +  case Op_SubI: case Op_SubL: case Op_SubF: case Op_SubD:
    1.51 +  case Op_MulI: case Op_MulL: case Op_MulF: case Op_MulD:
    1.52 +  case Op_DivF: case Op_DivD:
    1.53 +  case Op_AndI: case Op_AndL:
    1.54 +  case Op_OrI:  case Op_OrL:
    1.55 +  case Op_XorI: case Op_XorL:
    1.56 +    *start = 1;
    1.57 +    *end   = 3; // 2 vector operands
    1.58 +    break;
    1.59 +  case Op_CMoveI:  case Op_CMoveL:  case Op_CMoveF:  case Op_CMoveD:
    1.60 +    *start = 2;
    1.61 +    *end   = n->req();
    1.62 +    break;
    1.63 +  default:
    1.64 +    *start = 1;
    1.65 +    *end   = n->req(); // default is all operands
    1.66 +  }
    1.67 +}
    1.68 +
    1.69  // Return the vector version of a scalar operation node.
    1.70  VectorNode* VectorNode::make(Compile* C, int opc, Node* n1, Node* n2, uint vlen, BasicType bt) {
    1.71    const TypeVect* vt = TypeVect::make(bt, vlen);
    1.72 -  int vopc = VectorNode::opcode(opc, vlen, bt);
    1.73 +  int vopc = VectorNode::opcode(opc, bt);
    1.74  
    1.75    switch (vopc) {
    1.76    case Op_AddVB: return new (C, 3) AddVBNode(n1, n2, vt);
    1.77 @@ -278,38 +322,39 @@
    1.78    switch (bt) {
    1.79    case T_BOOLEAN:
    1.80    case T_BYTE:
    1.81 -    return new (C, vlen+1) PackBNode(s, vt);
    1.82 +    return new (C, 2) PackBNode(s, vt);
    1.83    case T_CHAR:
    1.84    case T_SHORT:
    1.85 -    return new (C, vlen+1) PackSNode(s, vt);
    1.86 +    return new (C, 2) PackSNode(s, vt);
    1.87    case T_INT:
    1.88 -    return new (C, vlen+1) PackINode(s, vt);
    1.89 +    return new (C, 2) PackINode(s, vt);
    1.90    case T_LONG:
    1.91 -    return new (C, vlen+1) PackLNode(s, vt);
    1.92 +    return new (C, 2) PackLNode(s, vt);
    1.93    case T_FLOAT:
    1.94 -    return new (C, vlen+1) PackFNode(s, vt);
    1.95 +    return new (C, 2) PackFNode(s, vt);
    1.96    case T_DOUBLE:
    1.97 -    return new (C, vlen+1) PackDNode(s, vt);
    1.98 +    return new (C, 2) PackDNode(s, vt);
    1.99    }
   1.100    ShouldNotReachHere();
   1.101    return NULL;
   1.102  }
   1.103  
   1.104  // Create a binary tree form for Packs. [lo, hi) (half-open) range
   1.105 -Node* PackNode::binaryTreePack(Compile* C, int lo, int hi) {
   1.106 +PackNode* PackNode::binary_tree_pack(Compile* C, int lo, int hi) {
   1.107    int ct = hi - lo;
   1.108    assert(is_power_of_2(ct), "power of 2");
   1.109    if (ct == 2) {
   1.110      PackNode* pk = PackNode::make(C, in(lo), 2, vect_type()->element_basic_type());
   1.111 -    pk->add_opd(1, in(lo+1));
   1.112 +    pk->add_opd(in(lo+1));
   1.113      return pk;
   1.114  
   1.115    } else {
   1.116      int mid = lo + ct/2;
   1.117 -    Node* n1 = binaryTreePack(C, lo,  mid);
   1.118 -    Node* n2 = binaryTreePack(C, mid, hi );
   1.119 +    PackNode* n1 = binary_tree_pack(C, lo,  mid);
   1.120 +    PackNode* n2 = binary_tree_pack(C, mid, hi );
   1.121  
   1.122 -    BasicType bt = vect_type()->element_basic_type();
   1.123 +    BasicType bt = n1->vect_type()->element_basic_type();
   1.124 +    assert(bt == n2->vect_type()->element_basic_type(), "should be the same");
   1.125      switch (bt) {
   1.126      case T_BOOLEAN:
   1.127      case T_BYTE:

mercurial