247
247
TR_VectorAPIExpansion::buildVectorAliases (bool verifyMode)
248
248
{
249
249
if (_trace)
250
- traceMsg (comp (), " %s Aliasing symrefs verifyMode=%\n " , OPT_DETAILS_VECTOR, verifyMode);
250
+ traceMsg (comp (), " %s Aliasing symrefs verifyMode=%d \n " , OPT_DETAILS_VECTOR, verifyMode);
251
251
252
252
_visitedNodes.empty ();
253
253
@@ -409,14 +409,7 @@ TR_VectorAPIExpansion::visitNodeToBuildVectorAliases(TR::Node *node, bool verify
409
409
if (getSecondClassIndex (methodSymbol) != -1 )
410
410
getObjectTypeFromClassNode (comp (), node->getChild (getSecondClassIndex (methodSymbol)));
411
411
412
- if (methodSymbol->getRecognizedMethod () == TR::jdk_internal_vm_vector_VectorSupport_load ||
413
- methodSymbol->getRecognizedMethod () == TR::jdk_internal_vm_vector_VectorSupport_store ||
414
- methodSymbol->getRecognizedMethod () == TR::jdk_internal_vm_vector_VectorSupport_fromBitsCoerced ||
415
- methodSymbol->getRecognizedMethod () == TR::jdk_internal_vm_vector_VectorSupport_binaryOp)
416
- {
417
- objectType = objectTypeFromClass;
418
- }
419
- else if (methodSymbol->getRecognizedMethod () == TR::jdk_internal_vm_vector_VectorSupport_compressExpandOp)
412
+ if (methodSymbol->getRecognizedMethod () == TR::jdk_internal_vm_vector_VectorSupport_compressExpandOp)
420
413
{
421
414
if (!node->getFirstChild ()->getOpCode ().isLoadConst ())
422
415
{
@@ -431,9 +424,9 @@ TR_VectorAPIExpansion::visitNodeToBuildVectorAliases(TR::Node *node, bool verify
431
424
objectType = Vector;
432
425
}
433
426
}
434
- else
427
+ else if (objectType == Unknown)
435
428
{
436
- TR_ASSERT_FATAL ( objectType != Unknown, " Object type should be known " ) ;
429
+ objectType = objectTypeFromClass ;
437
430
}
438
431
}
439
432
@@ -674,7 +667,8 @@ TR_VectorAPIExpansion::visitNodeToBuildVectorAliases(TR::Node *node, bool verify
674
667
}
675
668
else if (boxingAllowed () &&
676
669
(node->getOpCodeValue () == TR::checkcast ||
677
- node->getOpCodeValue () == TR::athrow))
670
+ node->getOpCodeValue () == TR::athrow ||
671
+ node->getOpCodeValue () == TR::awrtbar))
678
672
{
679
673
// do nothing here to allow this treetop when boxing is enabled
680
674
}
@@ -1054,7 +1048,7 @@ TR_VectorAPIExpansion::getObjectTypeFromClassNode(TR::Compilation *comp, TR::Nod
1054
1048
1055
1049
if ((*(*_boxingClasses[objectType - 1 ])[vectorLength - 1 ])[elementType - 1 ] == NULL )
1056
1050
{
1057
- traceMsg (comp, " Caching class for boxing: %d %d %d" , objectType, vectorLength, elementType);
1051
+ traceMsg (comp, " Caching class for boxing: %d %d %d\n " , objectType, vectorLength, elementType);
1058
1052
1059
1053
(*(*_boxingClasses[objectType - 1 ])[vectorLength - 1 ])[elementType - 1 ] = clazz;
1060
1054
}
@@ -1427,8 +1421,8 @@ TR_VectorAPIExpansion::dontVectorizeNode(TR::Node *node)
1427
1421
1428
1422
1429
1423
bool
1430
- TR_VectorAPIExpansion::isVectorizedOrScalarizedNode (TR::Node *node, TR::DataType &elementType, int32_t &bitsLength,
1431
- vapiObjType &objectType, bool &scalarized)
1424
+ TR_VectorAPIExpansion::isVectorizedOrScalarizedNode (TR::Node *node, TR::DataType &elementType, vec_sz_t &bitsLength,
1425
+ vapiObjType &objectType, bool &scalarized, bool sourceType )
1432
1426
{
1433
1427
// TODO: do not override if not vectorized
1434
1428
elementType = TR::NoType;
@@ -1482,10 +1476,24 @@ TR_VectorAPIExpansion::isVectorizedOrScalarizedNode(TR::Node *node, TR::DataType
1482
1476
if (_aliasTable[classId]._classId <= 0 )
1483
1477
return false ;
1484
1478
1485
- elementType = _nodeTable[nodeIndex]._elementType ;
1486
- bitsLength = _nodeTable[nodeIndex]._vecLen ;
1487
1479
objectType = _nodeTable[nodeIndex]._objectType ;
1488
1480
1481
+ TR::MethodSymbol *methodSymbol = node->getSymbolReference ()->getSymbol ()->castToMethodSymbol ();
1482
+
1483
+ if (sourceType &&
1484
+ methodSymbol->getRecognizedMethod () == TR::jdk_internal_vm_vector_VectorSupport_convert)
1485
+ {
1486
+ // source type of two-type opcodes is not stored in the _nodeTable
1487
+ // so we need to analyze the node again
1488
+ bool result = getConvertSourceType (this , node, elementType, bitsLength);
1489
+ TR_ASSERT_FATAL (result, " Conversion source type should be known\n " );
1490
+ }
1491
+ else
1492
+ {
1493
+ elementType = _nodeTable[nodeIndex]._elementType ;
1494
+ bitsLength = _nodeTable[nodeIndex]._vecLen ;
1495
+ }
1496
+
1489
1497
if (!_nodeTable[nodeIndex]._canVectorize )
1490
1498
scalarized = true ;
1491
1499
@@ -1502,9 +1510,16 @@ TR_VectorAPIExpansion::isVectorizedOrScalarizedNode(TR::Node *node, TR::DataType
1502
1510
{
1503
1511
ncount_t nodeIndex = node->getGlobalIndex ();
1504
1512
1513
+ objectType = _nodeTable[nodeIndex]._objectType ;
1514
+
1515
+ TR::MethodSymbol *methodSymbol = origSymRef->getSymbol ()->castToMethodSymbol ();
1516
+
1517
+
1518
+ TR_ASSERT_FATAL (!sourceType, " Node could not be vectorized if we are asking for its source type\n " );
1519
+
1505
1520
elementType = _nodeTable[nodeIndex]._elementType ;
1506
1521
bitsLength = _nodeTable[nodeIndex]._vecLen ;
1507
- objectType = _nodeTable[nodeIndex]. _objectType ;
1522
+
1508
1523
return true ;
1509
1524
}
1510
1525
@@ -1558,7 +1573,7 @@ TR_VectorAPIExpansion::boxChild(TR::TreeTop *treeTop, TR::Node *node, uint32_t i
1558
1573
TR::Node *child = node->getChild (i);
1559
1574
1560
1575
TR::DataType elementType;
1561
- int32_t bitsLength;
1576
+ vec_sz_t bitsLength;
1562
1577
vapiObjType objectType;
1563
1578
bool scalarized;
1564
1579
TR::ILOpCodes maskStoreOpCode;
@@ -1590,7 +1605,12 @@ TR_VectorAPIExpansion::boxChild(TR::TreeTop *treeTop, TR::Node *node, uint32_t i
1590
1605
{
1591
1606
vecClass = getClassForBoxing (child, elementType, bitsLength, objectType);
1592
1607
if (!vecClass)
1608
+ {
1609
+ if (_trace)
1610
+ traceMsg (comp (), " Missing class for boxing of %d child of node %p\n " , i, node);
1611
+
1593
1612
boxingSupported = false ;
1613
+ }
1594
1614
}
1595
1615
1596
1616
if (!boxingSupported ||
@@ -1603,8 +1623,7 @@ TR_VectorAPIExpansion::boxChild(TR::TreeTop *treeTop, TR::Node *node, uint32_t i
1603
1623
_aliasTable[classId]._classId = -1 ;
1604
1624
1605
1625
if (_trace)
1606
- traceMsg (comp (), " Invalidated class #%d due to unsupported boxing of %d child of node %p in %s\n " ,
1607
- classId, i, node, comp ()->signature ());
1626
+ traceMsg (comp (), " Invalidated class #%d due to unsupported boxing of %d child of node %p\n " , classId, i, node);
1608
1627
return false ;
1609
1628
}
1610
1629
@@ -1677,7 +1696,9 @@ TR_VectorAPIExpansion::boxChild(TR::TreeTop *treeTop, TR::Node *node, uint32_t i
1677
1696
treeTop->insertBefore (TR::TreeTop::create (comp (), fence));
1678
1697
1679
1698
if (_trace)
1680
- traceMsg (comp (), " Boxed child %d of node %p into %p\n " , i, node, newObject);
1699
+ traceMsg (comp (), " Boxed %s%d%s child %d of node %p into %p\n " ,
1700
+ objectType == Vector ? " Vector" : " Mask" , bitsLength, TR::DataType::getName (elementType),
1701
+ i, node, newObject);
1681
1702
1682
1703
if (TR::Options::getVerboseOption (TR_VerboseVectorAPI))
1683
1704
{
@@ -1695,11 +1716,11 @@ TR_VectorAPIExpansion::unboxNode(TR::Node *parentNode, TR::Node *operand, vapiOb
1695
1716
bool checkBoxing)
1696
1717
{
1697
1718
TR::DataType elementType;
1698
- int32_t bitsLength;
1719
+ vec_sz_t bitsLength;
1699
1720
vapiObjType parentType;
1700
1721
bool parentScalarized;
1701
1722
bool parentVectorizedOrScalarized = isVectorizedOrScalarizedNode (parentNode, elementType, bitsLength,
1702
- parentType, parentScalarized);
1723
+ parentType, parentScalarized, true );
1703
1724
1704
1725
TR_ASSERT_FATAL (parentVectorizedOrScalarized, " Node %p should be vectorized or scalarized since we are trying to unbox its operand %p" ,
1705
1726
parentNode, operand);
@@ -1728,7 +1749,12 @@ TR_VectorAPIExpansion::unboxNode(TR::Node *parentNode, TR::Node *operand, vapiOb
1728
1749
{
1729
1750
vecClass = getClassForBoxing (operand, elementType, bitsLength, operandObjectType);
1730
1751
if (!vecClass)
1752
+ {
1753
+ if (_trace)
1754
+ traceMsg (comp (), " Missing class for unboxing of operand %p of node %p\n " , operand, parentNode);
1755
+
1731
1756
unboxingSupported = false ;
1757
+ }
1732
1758
}
1733
1759
1734
1760
if (!unboxingSupported)
@@ -1741,8 +1767,8 @@ TR_VectorAPIExpansion::unboxNode(TR::Node *parentNode, TR::Node *operand, vapiOb
1741
1767
_aliasTable[classId]._classId = -1 ;
1742
1768
1743
1769
if (_trace)
1744
- traceMsg (comp (), " Invalidated class #%d due to unsupported unboxing of operand %p of node %p in %s \n " ,
1745
- classId, operand, parentNode, comp ()-> signature () );
1770
+ traceMsg (comp (), " Invalidated class #%d due to unsupported unboxing of operand %p of node %p\n " ,
1771
+ classId, operand, parentNode);
1746
1772
1747
1773
return NULL ;
1748
1774
}
@@ -1784,7 +1810,9 @@ TR_VectorAPIExpansion::unboxNode(TR::Node *parentNode, TR::Node *operand, vapiOb
1784
1810
}
1785
1811
1786
1812
if (_trace)
1787
- traceMsg (comp (), " Unboxed node %p into new node %p for parent %p\n " , operand, newOperand, parentNode);
1813
+ traceMsg (comp (), " Unboxed %s%d%s node %p into new node %p for parent %p\n " ,
1814
+ operandObjectType == Vector ? " Vector" : " Mask" , bitsLength, TR::DataType::getName (elementType),
1815
+ operand, newOperand, parentNode);
1788
1816
1789
1817
if (TR::Options::getVerboseOption (TR_VerboseVectorAPI))
1790
1818
{
@@ -1857,11 +1885,14 @@ TR_VectorAPIExpansion::transformIL(bool checkBoxing)
1857
1885
1858
1886
bool scalarized;
1859
1887
TR::DataType elementType;
1860
- int32_t bitsLength;
1888
+ vec_sz_t bitsLength;
1861
1889
vapiObjType objectType;
1862
-
1863
1890
bool vectorizedOrScalarizedNode = isVectorizedOrScalarizedNode (node, elementType, bitsLength, objectType, scalarized);
1864
1891
1892
+ if (_trace)
1893
+ traceMsg (comp (), " Node %p (%s) vectorizedOrScalarized=%d elementType=%d bitsLength=%d objectType=%d scalarized=%d\n " ,
1894
+ node, opCode.getName (), vectorizedOrScalarizedNode, elementType.getDataType (), bitsLength, objectType, scalarized);
1895
+
1865
1896
// Vectorize intrinsic if its operands are known
1866
1897
if (boxingAllowed () &&
1867
1898
!vectorizedOrScalarizedNode &&
@@ -1879,7 +1910,7 @@ TR_VectorAPIExpansion::transformIL(bool checkBoxing)
1879
1910
1880
1911
bool operandScalarized;
1881
1912
TR::DataType operandElementType;
1882
- int32_t operandBitsLength;
1913
+ vec_sz_t operandBitsLength;
1883
1914
vapiObjType operandObjectType;
1884
1915
1885
1916
bool operandVectorizedOrScalarized = isVectorizedOrScalarizedNode (operand, operandElementType, operandBitsLength,
@@ -1935,7 +1966,8 @@ TR_VectorAPIExpansion::transformIL(bool checkBoxing)
1935
1966
opCodeValue == TR::areturn ||
1936
1967
opCodeValue == TR::aRegStore ||
1937
1968
opCodeValue == TR::checkcast ||
1938
- opCodeValue == TR::athrow))
1969
+ opCodeValue == TR::athrow ||
1970
+ opCodeValue == TR::awrtbar))
1939
1971
{
1940
1972
if (_trace)
1941
1973
traceMsg (comp (), " Checking if children of non-vector node %p need to be boxed\n " , node);
@@ -2028,7 +2060,7 @@ TR_VectorAPIExpansion::transformIL(bool checkBoxing)
2028
2060
if (boxingAllowed ())
2029
2061
{
2030
2062
TR::DataType rhsElementType;
2031
- int32_t rhsBitsLength;
2063
+ vec_sz_t rhsBitsLength;
2032
2064
vapiObjType rhsObjectType;
2033
2065
bool rhsScalarized;
2034
2066
bool rhsVectorizedOrScalarized = isVectorizedOrScalarizedNode (node->getFirstChild (), rhsElementType, rhsBitsLength,
@@ -2079,7 +2111,7 @@ TR_VectorAPIExpansion::transformIL(bool checkBoxing)
2079
2111
bool vectorizedOrScalarized = false ;
2080
2112
2081
2113
TR::DataType operandElementType;
2082
- int32_t operandBitsLength;
2114
+ vec_sz_t operandBitsLength;
2083
2115
vapiObjType operandObjectType;
2084
2116
bool operandScalarized;
2085
2117
@@ -2088,8 +2120,10 @@ TR_VectorAPIExpansion::transformIL(bool checkBoxing)
2088
2120
2089
2121
if (!vectorizedOrScalarized)
2090
2122
{
2091
- TR_ASSERT_FATAL (operand->getOpCodeValue () == TR::aload || operand->getOpCodeValue () == TR::acall,
2092
- " Operand can only be aload or acall" );
2123
+ TR_ASSERT_FATAL (operand->getOpCodeValue () == TR::aload ||
2124
+ operand->getOpCodeValue () == TR::acall ||
2125
+ operand->getOpCodeValue () == TR::New,
2126
+ " Operand can only be aload, acall, or New (child %d)" , i);
2093
2127
vapiObjType operandObjectType = Vector;
2094
2128
2095
2129
if (getArgumentType (methodSymbol, i) == Mask)
@@ -2874,6 +2908,41 @@ TR::Node *TR_VectorAPIExpansion::transformRORtoROL(TR_VectorAPIExpansion *opt, T
2874
2908
return subNode;
2875
2909
}
2876
2910
2911
+ bool
2912
+ TR_VectorAPIExpansion::getConvertSourceType (TR_VectorAPIExpansion *opt, TR::Node *node,
2913
+ TR::DataType &sourceElementType, vec_sz_t &bitsLength)
2914
+ {
2915
+ TR::Compilation *comp = opt->comp ();
2916
+ bitsLength = vec_len_default;
2917
+
2918
+ // For convert, source vector type info is in children 2 and 3
2919
+ TR::Node *sourceElementTypeNode = node->getChild (2 );
2920
+ sourceElementType = getDataTypeFromClassNode (comp, sourceElementTypeNode);
2921
+
2922
+ TR::Node *sourceNumLanesNode = node->getChild (3 );
2923
+
2924
+ if (sourceNumLanesNode->getOpCode ().isLoadConst ())
2925
+ {
2926
+ int32_t elementSize = OMR::DataType::getSize (sourceElementType);
2927
+ bitsLength = sourceNumLanesNode->get32bitIntegralValue ()*8 *elementSize;
2928
+
2929
+ if (supportedOnPlatform (comp, bitsLength) == TR::NoVectorLength)
2930
+ {
2931
+ traceMsg (comp, " Platform does not support conversion source length %d in node %p\n " ,
2932
+ bitsLength, node);
2933
+ return false ;
2934
+ }
2935
+ }
2936
+
2937
+ if (sourceElementType == TR::NoType || bitsLength == vec_len_default)
2938
+ {
2939
+ traceMsg (comp, " Unknown conversion source type in node %p\n " , node);
2940
+ return false ;
2941
+ }
2942
+
2943
+ return true ;
2944
+ }
2945
+
2877
2946
2878
2947
TR::Node *TR_VectorAPIExpansion::naryIntrinsicHandler (TR_VectorAPIExpansion *opt, TR::TreeTop *treeTop, TR::Node *node,
2879
2948
TR::DataType elementType, TR::VectorLength vectorLength, vapiObjType objectType,
@@ -2964,32 +3033,12 @@ TR::Node *TR_VectorAPIExpansion::naryIntrinsicHandler(TR_VectorAPIExpansion *opt
2964
3033
2965
3034
if (opCodeType == Convert)
2966
3035
{
2967
- // source vector type info is in children 2 and 3
2968
- TR::Node *sourceElementTypeNode = node->getChild (2 );
2969
- sourceElementType = getDataTypeFromClassNode (comp, sourceElementTypeNode);
3036
+ vec_sz_t bitsLength = vec_len_default;
2970
3037
2971
- TR::Node *sourceNumLanesNode = node->getChild (3 );
2972
-
2973
- if (sourceNumLanesNode->getOpCode ().isLoadConst ())
2974
- {
2975
- int32_t elementSize = OMR::DataType::getSize (sourceElementType);
2976
- vec_sz_t bitsLength = sourceNumLanesNode->get32bitIntegralValue ()*8 *elementSize;
2977
-
2978
- if (supportedOnPlatform (comp, bitsLength) == TR::NoVectorLength)
2979
- {
2980
- traceMsg (comp, " Platform does not support conversion source length %d in node %p" ,
2981
- bitsLength, node);
2982
- return NULL ;
2983
- }
2984
-
2985
- sourceVectorLength = OMR::DataType::bitsToVectorLength (bitsLength);
2986
- }
2987
-
2988
- if (sourceElementType == TR::NoType || sourceVectorLength == TR::NoVectorLength)
2989
- {
2990
- traceMsg (comp, " Unknown conversion source type in node %p" , node);
3038
+ if (!getConvertSourceType (opt, node, sourceElementType, bitsLength))
2991
3039
return NULL ;
2992
- }
3040
+
3041
+ sourceVectorLength = OMR::DataType::bitsToVectorLength (bitsLength);
2993
3042
}
2994
3043
else if (opCodeType == Compare)
2995
3044
{
@@ -3249,6 +3298,8 @@ TR::ILOpCodes TR_VectorAPIExpansion::ILOpcodeFromVectorAPIOpcode(TR::Compilation
3249
3298
{
3250
3299
if (scalar) return TR::BadILOp;
3251
3300
3301
+ if (objectType == Mask) return reportMissingOpCode (comp, vectorAPIOpCode, objectType, opCodeType, withMask);
3302
+
3252
3303
switch (vectorAPIOpCode)
3253
3304
{
3254
3305
case VECTOR_OP_CAST:
@@ -3674,12 +3725,12 @@ TR_VectorAPIExpansion::vapiObjTypeNames[] =
3674
3725
{
3675
3726
" Unknown" ,
3676
3727
" Vector" ,
3728
+ " Mask" ,
3729
+ " Shuffle" ,
3677
3730
" Species" ,
3678
3731
" ElementType" ,
3679
3732
" NumLanes" ,
3680
- " Mask" ,
3681
3733
" Scalar" ,
3682
- " Shuffle" ,
3683
3734
" Invalid"
3684
3735
};
3685
3736
0 commit comments