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

[release/5.0] Fix logic to test bits in a constant vector (Vector256) #48613

Merged
merged 3 commits into from
Mar 10, 2021
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
22 changes: 22 additions & 0 deletions src/coreclr/src/jit/lower.h
Original file line number Diff line number Diff line change
Expand Up @@ -348,6 +348,28 @@ class Lowering final : public Phase
double f64[4];
};

//----------------------------------------------------------------------------------------------
// VectorConstantIsBroadcastedI64: Check N i64 elements in a constant vector for equality
//
// Arguments:
// vecCns - Constant vector
// count - Amount of i64 components to compare
//
// Returns:
// true if N i64 elements of the given vector are equal
static bool VectorConstantIsBroadcastedI64(VectorConstant& vecCns, int count)
{
assert(count >= 1 && count <= 4);
for (int i = 1; i < count; i++)
{
if (vecCns.i64[i] != vecCns.i64[0])
{
return false;
}
}
return true;
}

//----------------------------------------------------------------------------------------------
// ProcessArgForHWIntrinsicCreate: Processes an argument for the Lowering::LowerHWIntrinsicCreate method
//
Expand Down
16 changes: 7 additions & 9 deletions src/coreclr/src/jit/lowerarmarch.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -969,25 +969,23 @@ void Lowering::LowerHWIntrinsicCreate(GenTreeHWIntrinsic* node)

assert((simdSize == 8) || (simdSize == 16));

if ((argCnt == 1) || (simdSize == 8) || (vecCns.i64[0] == vecCns.i64[1]))
if (VectorConstantIsBroadcastedI64(vecCns, simdSize / 8))
{
// If we are a single constant or if all parts are the same, we might be able to optimize
// this even further for certain values, such as Zero or AllBitsSet.

if (vecCns.i64[0] == 0)
{
node->gtOp1 = nullptr;
node->gtOp2 = nullptr;

node->gtHWIntrinsicId = NI_Vector128_get_Zero;
node->gtOp1 = nullptr;
node->gtOp2 = nullptr;
node->gtHWIntrinsicId = (simdSize == 8) ? NI_Vector64_get_Zero : NI_Vector128_get_Zero;
return;
}
else if (vecCns.i64[0] == -1)
{
node->gtOp1 = nullptr;
node->gtOp2 = nullptr;

node->gtHWIntrinsicId = NI_Vector128_get_AllBitsSet;
node->gtOp1 = nullptr;
node->gtOp2 = nullptr;
node->gtHWIntrinsicId = (simdSize == 8) ? NI_Vector64_get_AllBitsSet : NI_Vector128_get_AllBitsSet;
return;
}
}
Expand Down
17 changes: 7 additions & 10 deletions src/coreclr/src/jit/lowerxarch.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1516,26 +1516,23 @@ void Lowering::LowerHWIntrinsicCreate(GenTreeHWIntrinsic* node)

assert((simdSize == 8) || (simdSize == 12) || (simdSize == 16) || (simdSize == 32));

if ((argCnt == 1) ||
((vecCns.i64[0] == vecCns.i64[1]) && ((simdSize <= 16) || (vecCns.i64[2] == vecCns.i64[3]))))
if (((simdSize == 16) || (simdSize == 32)) && VectorConstantIsBroadcastedI64(vecCns, simdSize / 8))
{
// If we are a single constant or if all parts are the same, we might be able to optimize
// this even further for certain values, such as Zero or AllBitsSet.

if (vecCns.i64[0] == 0)
{
node->gtOp1 = nullptr;
node->gtOp2 = nullptr;

node->gtHWIntrinsicId = NI_Vector128_get_Zero;
node->gtOp1 = nullptr;
node->gtOp2 = nullptr;
node->gtHWIntrinsicId = (simdSize == 16) ? NI_Vector128_get_Zero : NI_Vector256_get_Zero;
return;
}
else if (vecCns.i64[0] == -1)
{
node->gtOp1 = nullptr;
node->gtOp2 = nullptr;

node->gtHWIntrinsicId = NI_Vector128_get_AllBitsSet;
node->gtOp1 = nullptr;
node->gtOp2 = nullptr;
node->gtHWIntrinsicId = (simdSize == 16) ? NI_Vector128_get_AllBitsSet : NI_Vector256_get_AllBitsSet;
return;
}
}
Expand Down
3 changes: 3 additions & 0 deletions src/coreclr/tests/issues.targets
Original file line number Diff line number Diff line change
Expand Up @@ -955,6 +955,9 @@
<ExcludeList Include="$(XunitTestBinBase)/JIT/HardwareIntrinsics/General/Regression/GitHub_43569/**">
<Issue>https://github.com/dotnet/runtime/issues/43676</Issue>
</ExcludeList>
<ExcludeList Include="$(XunitTestBinBase)/JIT/HardwareIntrinsics/General/Regression/GitHub_47236/**">
<Issue>https://github.com/dotnet/runtime/issues/43676</Issue>
</ExcludeList>
<ExcludeList Include="$(XunitTestBinBase)/baseservices/TieredCompilation/BasicTestWithMcj/*">
<Issue>Tests features specific to coreclr</Issue>
</ExcludeList>
Expand Down
Loading