Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix the return type of VectorSupport.fromBitsCoerced #16330

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
31 changes: 26 additions & 5 deletions runtime/compiler/optimizer/VectorAPIExpansion.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -207,10 +207,30 @@ TR_VectorAPIExpansion::visitNodeToBuildVectorAliases(TR::Node *node)
_aliasTable[methodRefNum]._objectType = getReturnType(methodSymbol);

if (_aliasTable[methodRefNum]._objectType == Unknown &&
isVectorAPICall &&
methodSymbol->getRecognizedMethod() == TR::jdk_internal_vm_vector_VectorSupport_load)
isVectorAPICall)
{
_aliasTable[methodRefNum]._objectType = getObjectTypeFromClassNode(comp(), node->getFirstChild());
if (methodSymbol->getRecognizedMethod() == TR::jdk_internal_vm_vector_VectorSupport_load)
{
_aliasTable[methodRefNum]._objectType = getObjectTypeFromClassNode(comp(), node->getFirstChild());
}
else if (methodSymbol->getRecognizedMethod() == TR::jdk_internal_vm_vector_VectorSupport_fromBitsCoerced)
{
TR::Node *broadcastTypeNode = node->getChild(BROADCAST_TYPE_CHILD);

if (!broadcastTypeNode->getOpCode().isLoadConst())
{
if (_trace) traceMsg(comp(), "Unknown broadcast type in node %p\n", node);
}
else
{
int32_t broadcastType = broadcastTypeNode->get32bitIntegralValue();

TR_ASSERT_FATAL(broadcastType == MODE_BROADCAST || broadcastType == MODE_BITS_COERCED_LONG_TO_MASK,
"Unexpected broadcast type in node %p\n", node);

_aliasTable[methodRefNum]._objectType =(broadcastType == MODE_BROADCAST) ? Vector : Mask;
}
}
}

for (int32_t i = 0; i < numChildren; i++)
Expand Down Expand Up @@ -1810,7 +1830,8 @@ TR::Node *TR_VectorAPIExpansion::fromBitsCoercedIntrinsicHandler(TR_VectorAPIExp

TR::Node *newNode;

switch (elementType) {
int32_t type = mask ? TR::Int64 : elementType;
switch (type) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Will we still generate vsplats? Maybe we need to introduce msplats?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

When broadcastType == MODE_BITS_COERCED_LONG_TO_MASK, opcode we generate is mLongBitsToMask. In that case, the source type of the conversion must be long instead of the element type.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Oh, right, of course, we do generate the right opcode! Then everything looks good to me.

case TR::Float:
newNode = TR::Node::create(node, TR::ibits2f, 1, TR::Node::create(node, TR::l2i, 1, valueToBroadcast));
break;
Expand Down Expand Up @@ -2158,7 +2179,7 @@ TR_VectorAPIExpansion::methodTable[] =
{binaryIntrinsicHandler, Vector, {Unknown, Unknown, Unknown, ElementType, NumLanes, Vector, Vector, Mask}}, // jdk_internal_vm_vector_VectorSupport_binaryOp
{blendIntrinsicHandler, Vector, {Unknown, Unknown, ElementType, NumLanes, Vector, Vector, Vector, Unknown}}, // jdk_internal_vm_vector_VectorSupport_blend
{compareIntrinsicHandler, Mask, {Unknown, Unknown, Unknown, ElementType, NumLanes, Vector, Vector, Mask}}, // jdk_internal_vm_vector_VectorSupport_compare
{fromBitsCoercedIntrinsicHandler, Vector, {Unknown, ElementType, NumLanes, Unknown, Unknown, Unknown}}, // jdk_internal_vm_vector_VectorSupport_fromBitsCoerced
{fromBitsCoercedIntrinsicHandler, Unknown, {Unknown, ElementType, NumLanes, Unknown, Unknown, Unknown}}, // jdk_internal_vm_vector_VectorSupport_fromBitsCoerced
{maskReductionCoercedIntrinsicHandler, Scalar, {Unknown, Unknown, ElementType, NumLanes, Mask}}, // jdk_internal_vm_vector_VectorSupport_maskReductionCoerced
{reductionCoercedIntrinsicHandler, Scalar, {Unknown, Unknown, Unknown, ElementType, NumLanes, Vector, Mask}}, // jdk_internal_vm_vector_VectorSupport_reductionCoerced
{ternaryIntrinsicHandler, Vector, {Unknown, Unknown, Unknown, ElementType, NumLanes, Vector, Vector, Vector, Mask}}, // jdk_internal_vm_vector_VectorSupport_ternaryOp
Expand Down
3 changes: 3 additions & 0 deletions runtime/compiler/optimizer/VectorAPIExpansion.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -148,6 +148,9 @@ class TR_VectorAPIExpansion : public TR::Optimization
static int32_t const MODE_BROADCAST = 0;
static int32_t const MODE_BITS_COERCED_LONG_TO_MASK = 1;

// Position of the parameters in the intrinsics.
static int32_t const BROADCAST_TYPE_CHILD = 4;

/** \brief
* Is passed to methods handlers during analysis and transforamtion phases
*
Expand Down