< prev index next >

src/hotspot/share/adlc/formssel.cpp

Print this page
*** 2279,10 ***
--- 2279,11 ---
    if (strcmp(name, "RegI") == 0) size = 1;
    if (strcmp(name, "RegF") == 0) size = 1;
    if (strcmp(name, "RegD") == 0) size = 2;
    if (strcmp(name, "RegL") == 0) size = 2;
    if (strcmp(name, "RegN") == 0) size = 1;
+   if (strcmp(name, "RegVectMask") == 0) size = globalAD->get_preproc_def("AARCH64") ? 1 : 2;
    if (strcmp(name, "VecX") == 0) size = 4;
    if (strcmp(name, "VecY") == 0) size = 8;
    if (strcmp(name, "VecZ") == 0) size = 16;
    if (strcmp(name, "RegP") == 0) size = globalAD->get_preproc_def("_LP64") ? 2 : 1;
    if (size == 0) {

*** 3512,11 ***
    static const char *needs_ideal_memory_list[] = {
      "StoreI","StoreL","StoreP","StoreN","StoreNKlass","StoreD","StoreF" ,
      "StoreB","StoreC","Store" ,"StoreFP",
      "LoadI", "LoadL", "LoadP" ,"LoadN", "LoadD" ,"LoadF"  ,
      "LoadB" , "LoadUB", "LoadUS" ,"LoadS" ,"Load" ,
!     "StoreVector", "LoadVector", "LoadVectorGather", "StoreVectorScatter", "LoadVectorMasked", "StoreVectorMasked",
      "LoadRange", "LoadKlass", "LoadNKlass", "LoadL_unaligned", "LoadD_unaligned",
      "LoadPLocked",
      "StorePConditional", "StoreIConditional", "StoreLConditional",
      "CompareAndSwapB", "CompareAndSwapS", "CompareAndSwapI", "CompareAndSwapL", "CompareAndSwapP", "CompareAndSwapN",
      "WeakCompareAndSwapB", "WeakCompareAndSwapS", "WeakCompareAndSwapI", "WeakCompareAndSwapL", "WeakCompareAndSwapP", "WeakCompareAndSwapN",
--- 3513,12 ---
    static const char *needs_ideal_memory_list[] = {
      "StoreI","StoreL","StoreP","StoreN","StoreNKlass","StoreD","StoreF" ,
      "StoreB","StoreC","Store" ,"StoreFP",
      "LoadI", "LoadL", "LoadP" ,"LoadN", "LoadD" ,"LoadF"  ,
      "LoadB" , "LoadUB", "LoadUS" ,"LoadS" ,"Load" ,
!     "StoreVector", "LoadVector", "LoadVectorMasked", "StoreVectorMasked",
+     "LoadVectorGather", "StoreVectorScatter", "LoadVectorGatherMasked", "StoreVectorScatterMasked",
      "LoadRange", "LoadKlass", "LoadNKlass", "LoadL_unaligned", "LoadD_unaligned",
      "LoadPLocked",
      "StorePConditional", "StoreIConditional", "StoreLConditional",
      "CompareAndSwapB", "CompareAndSwapS", "CompareAndSwapI", "CompareAndSwapL", "CompareAndSwapP", "CompareAndSwapN",
      "WeakCompareAndSwapB", "WeakCompareAndSwapS", "WeakCompareAndSwapI", "WeakCompareAndSwapL", "WeakCompareAndSwapP", "WeakCompareAndSwapN",

*** 3816,55 ***
  
    // We've made it through the gauntlet.
    return true;
  }
  
! //-------------------------- has_commutative_op -------------------------------
  // Recursively check for commutative operations with subtree operands
  // which could be swapped.
  void MatchNode::count_commutative_op(int& count) {
    static const char *commut_op_list[] = {
      "AddI","AddL","AddF","AddD",
-     "AddVB","AddVS","AddVI","AddVL","AddVF","AddVD",
      "AndI","AndL",
-     "AndV",
      "MaxI","MinI","MaxF","MinF","MaxD","MinD",
-     "MaxV", "MinV",
      "MulI","MulL","MulF","MulD",
-     "MulVB","MulVS","MulVI","MulVL","MulVF","MulVD",
      "OrI","OrL",
!     "OrV",
-     "XorI","XorL",
-     "XorV"
    };
-   int cnt = sizeof(commut_op_list)/sizeof(char*);
  
!   if( _lChild && _rChild && (_lChild->_lChild || _rChild->_lChild) ) {
      // Don't swap if right operand is an immediate constant.
      bool is_const = false;
!     if( _rChild->_lChild == NULL && _rChild->_rChild == NULL ) {
        FormDict &globals = _AD.globalNames();
        const Form *form = globals[_rChild->_opType];
!       if ( form ) {
!         OperandForm  *oper = form->is_operand();
!         if( oper && oper->interface_type(globals) == Form::constant_interface )
            is_const = true;
        }
      }
!     if( !is_const ) {
!       for( int i=0; i<cnt; i++ ) {
!         if( strcmp(_opType, commut_op_list[i]) == 0 ) {
!           count++;
!           _commutative_id = count; // id should be > 0
            break;
          }
        }
      }
    }
!   if( _lChild )
      _lChild->count_commutative_op(count);
!   if( _rChild )
      _rChild->count_commutative_op(count);
  }
  
  //-------------------------- swap_commutative_op ------------------------------
  // Recursively swap specified commutative operation with subtree operands.
--- 3818,81 ---
  
    // We've made it through the gauntlet.
    return true;
  }
  
! //-------------------------- count_commutative_op -------------------------------
  // Recursively check for commutative operations with subtree operands
  // which could be swapped.
  void MatchNode::count_commutative_op(int& count) {
    static const char *commut_op_list[] = {
      "AddI","AddL","AddF","AddD",
      "AndI","AndL",
      "MaxI","MinI","MaxF","MinF","MaxD","MinD",
      "MulI","MulL","MulF","MulD",
      "OrI","OrL",
!     "XorI","XorL"
    };
  
!   static const char *commut_vector_op_list[] = {
+     "AddVB", "AddVS", "AddVI", "AddVL", "AddVF", "AddVD",
+     "MulVB", "MulVS", "MulVI", "MulVL", "MulVF", "MulVD",
+     "AndV", "OrV", "XorV",
+     "MaxV", "MinV"
+   };
+ 
+   if (_lChild && _rChild && (_lChild->_lChild || _rChild->_lChild)) {
      // Don't swap if right operand is an immediate constant.
      bool is_const = false;
!     if (_rChild->_lChild == NULL && _rChild->_rChild == NULL) {
        FormDict &globals = _AD.globalNames();
        const Form *form = globals[_rChild->_opType];
!       if (form) {
!         OperandForm *oper = form->is_operand();
!         if (oper && oper->interface_type(globals) == Form::constant_interface)
            is_const = true;
        }
      }
! 
!     if (!is_const) {
!       int scalar_cnt = sizeof(commut_op_list)/sizeof(char*);
!       int vector_cnt = sizeof(commut_vector_op_list)/sizeof(char*);
!       bool matched = false;
+ 
+       // Check the commutative vector op first. It's noncommutative if
+       // the current node is a masked vector op, since a mask value
+       // is added to the original vector node's input list and the original
+       // first two inputs are packed into one BinaryNode. So don't swap
+       // if one of the operands is a BinaryNode.
+       for (int i = 0; i < vector_cnt; i++) {
+         if (strcmp(_opType, commut_vector_op_list[i]) == 0) {
+           if (strcmp(_lChild->_opType, "Binary") != 0 &&
+               strcmp(_rChild->_opType, "Binary") != 0) {
+             count++;
+             _commutative_id = count; // id should be > 0
+           }
+           matched = true;
            break;
          }
        }
+ 
+       // Then check the scalar op if the current op is not in
+       // the commut_vector_op_list.
+       if (!matched) {
+         for (int i = 0; i < scalar_cnt; i++) {
+           if (strcmp(_opType, commut_op_list[i]) == 0) {
+             count++;
+             _commutative_id = count; // id should be > 0
+             break;
+           }
+         }
+       }
      }
    }
!   if (_lChild)
      _lChild->count_commutative_op(count);
!   if (_rChild)
      _rChild->count_commutative_op(count);
  }
  
  //-------------------------- swap_commutative_op ------------------------------
  // Recursively swap specified commutative operation with subtree operands.

*** 4086,10 ***
--- 4114,11 ---
          strcmp(opType,"MinReductionV")==0 ||
          strcmp(opType,"MaxReductionV")==0 ||
          strcmp(opType,"AndReductionV")==0 ||
          strcmp(opType,"OrReductionV")==0 ||
          strcmp(opType,"XorReductionV")==0 ||
+         strcmp(opType,"MaskAll")==0 ||
          0 /* 0 to line up columns nicely */ )
        return 1;
    }
    return 0;
  }

*** 4197,21 ***
      "LShiftVB","LShiftVS","LShiftVI","LShiftVL",
      "RShiftVB","RShiftVS","RShiftVI","RShiftVL",
      "URShiftVB","URShiftVS","URShiftVI","URShiftVL",
      "ReplicateB","ReplicateS","ReplicateI","ReplicateL","ReplicateF","ReplicateD",
      "RoundDoubleModeV","RotateLeftV" , "RotateRightV", "LoadVector","StoreVector",
!     "LoadVectorGather", "StoreVectorScatter",
      "VectorTest", "VectorLoadMask", "VectorStoreMask", "VectorBlend", "VectorInsert",
      "VectorRearrange","VectorLoadShuffle", "VectorLoadConst",
      "VectorCastB2X", "VectorCastS2X", "VectorCastI2X",
      "VectorCastL2X", "VectorCastF2X", "VectorCastD2X",
      "VectorMaskWrapper", "VectorMaskCmp", "VectorReinterpret","LoadVectorMasked","StoreVectorMasked",
      "FmaVD", "FmaVF","PopCountVI",
      // Next are not supported currently.
      "PackB","PackS","PackI","PackL","PackF","PackD","Pack2L","Pack2D",
!     "ExtractB","ExtractUB","ExtractC","ExtractS","ExtractI","ExtractL","ExtractF","ExtractD",
-     "VectorMaskCast"
    };
    int cnt = sizeof(vector_list)/sizeof(char*);
    if (_rChild) {
      const char  *opType = _rChild->_opType;
      for (int i=0; i<cnt; i++)
--- 4226,22 ---
      "LShiftVB","LShiftVS","LShiftVI","LShiftVL",
      "RShiftVB","RShiftVS","RShiftVI","RShiftVL",
      "URShiftVB","URShiftVS","URShiftVI","URShiftVL",
      "ReplicateB","ReplicateS","ReplicateI","ReplicateL","ReplicateF","ReplicateD",
      "RoundDoubleModeV","RotateLeftV" , "RotateRightV", "LoadVector","StoreVector",
!     "LoadVectorGather", "StoreVectorScatter", "LoadVectorGatherMasked", "StoreVectorScatterMasked",
      "VectorTest", "VectorLoadMask", "VectorStoreMask", "VectorBlend", "VectorInsert",
      "VectorRearrange","VectorLoadShuffle", "VectorLoadConst",
      "VectorCastB2X", "VectorCastS2X", "VectorCastI2X",
      "VectorCastL2X", "VectorCastF2X", "VectorCastD2X",
      "VectorMaskWrapper", "VectorMaskCmp", "VectorReinterpret","LoadVectorMasked","StoreVectorMasked",
      "FmaVD", "FmaVF","PopCountVI",
+     // Next are vector mask ops.
+     "MaskAll", "AndVMask", "OrVMask", "XorVMask", "VectorMaskCast",
      // Next are not supported currently.
      "PackB","PackS","PackI","PackL","PackF","PackD","Pack2L","Pack2D",
!     "ExtractB","ExtractUB","ExtractC","ExtractS","ExtractI","ExtractL","ExtractF","ExtractD"
    };
    int cnt = sizeof(vector_list)/sizeof(char*);
    if (_rChild) {
      const char  *opType = _rChild->_opType;
      for (int i=0; i<cnt; i++)
< prev index next >