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

Update the x86 hwintrinsic list to match the arm64 layout #35364

Merged
merged 2 commits into from
Apr 24, 2020
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
4 changes: 2 additions & 2 deletions src/coreclr/src/jit/gentree.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -17121,7 +17121,7 @@ GenTree* Compiler::gtGetSIMDZero(var_types simdType, var_types baseType, CORINFO
// We only return the HWIntrinsicNode if SSE is supported, since it is possible for
// the user to disable the SSE HWIntrinsic support via the COMPlus configuration knobs
// even though the hardware vector types are still available.
return gtNewSimdHWIntrinsicNode(simdType, NI_Vector128_Zero, baseType, size);
return gtNewSimdHWIntrinsicNode(simdType, NI_Vector128_get_Zero, baseType, size);
}
return nullptr;
case TYP_SIMD32:
Expand All @@ -17130,7 +17130,7 @@ GenTree* Compiler::gtGetSIMDZero(var_types simdType, var_types baseType, CORINFO
// We only return the HWIntrinsicNode if AVX is supported, since it is possible for
// the user to disable the AVX HWIntrinsic support via the COMPlus configuration knobs
// even though the hardware vector types are still available.
return gtNewSimdHWIntrinsicNode(simdType, NI_Vector256_Zero, baseType, size);
return gtNewSimdHWIntrinsicNode(simdType, NI_Vector256_get_Zero, baseType, size);
}
return nullptr;
default:
Expand Down
4 changes: 2 additions & 2 deletions src/coreclr/src/jit/hwintrinsic.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,8 @@
static const HWIntrinsicInfo hwIntrinsicInfoArray[] = {
// clang-format off
#if defined(TARGET_XARCH)
#define HARDWARE_INTRINSIC(id, name, isa, ival, size, numarg, t1, t2, t3, t4, t5, t6, t7, t8, t9, t10, category, flag) \
{NI_##id, name, InstructionSet_##isa, static_cast<int>(ival), static_cast<unsigned>(size), numarg, t1, t2, t3, t4, t5, t6, t7, t8, t9, t10, category, static_cast<HWIntrinsicFlag>(flag)},
#define HARDWARE_INTRINSIC(isa, name, size, numarg, t1, t2, t3, t4, t5, t6, t7, t8, t9, t10, category, flag) \
{NI_##isa##_##name, #name, InstructionSet_##isa, static_cast<unsigned>(size), numarg, t1, t2, t3, t4, t5, t6, t7, t8, t9, t10, category, static_cast<HWIntrinsicFlag>(flag)},
#include "hwintrinsiclistxarch.h"
#elif defined (TARGET_ARM64)
#define HARDWARE_INTRINSIC(isa, name, size, numarg, t1, t2, t3, t4, t5, t6, t7, t8, t9, t10, category, flag) \
Expand Down
194 changes: 185 additions & 9 deletions src/coreclr/src/jit/hwintrinsic.h
Original file line number Diff line number Diff line change
Expand Up @@ -223,21 +223,42 @@ enum class FloatComparisonMode : unsigned char
// _CMP_TRUE_US
UnorderedTrueSignaling = 31,
};

enum class FloatRoundingMode : unsigned char
{
// _MM_FROUND_TO_NEAREST_INT
ToNearestInteger = 0x00,

// _MM_FROUND_TO_NEG_INF
ToNegativeInfinity = 0x01,

// _MM_FROUND_TO_POS_INF
ToPositiveInfinity = 0x02,

// _MM_FROUND_TO_ZERO
ToZero = 0x03,

// _MM_FROUND_CUR_DIRECTION
CurrentDirection = 0x04,

// _MM_FROUND_RAISE_EXC
RaiseException = 0x00,

// _MM_FROUND_NO_EXC
NoException = 0x08,
};
#endif // TARGET_XARCH

struct HWIntrinsicInfo
{
NamedIntrinsic id;
const char* name;
CORINFO_InstructionSet isa;
#ifdef TARGET_XARCH
int ival;
#endif
unsigned simdSize;
int numArgs;
instruction ins[10];
HWIntrinsicCategory category;
HWIntrinsicFlag flags;
unsigned simdSize;
int numArgs;
instruction ins[10];
HWIntrinsicCategory category;
HWIntrinsicFlag flags;

static const HWIntrinsicInfo& lookup(NamedIntrinsic id);

Expand Down Expand Up @@ -289,7 +310,162 @@ struct HWIntrinsicInfo
#ifdef TARGET_XARCH
static int lookupIval(NamedIntrinsic id)
{
return lookup(id).ival;
switch (id)
{
case NI_SSE_CompareEqual:
case NI_SSE_CompareScalarEqual:
case NI_SSE2_CompareEqual:
case NI_SSE2_CompareScalarEqual:
case NI_AVX_CompareEqual:
{
Copy link
Contributor

Choose a reason for hiding this comment

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

Why to put curly braces around simple return statement? They are not needed here, they do not increase readability and I don't believe we use them in other places in the JIT. cc @dotnet/jit-contrib

Copy link
Member Author

Choose a reason for hiding this comment

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

Habit mostly. It minimizes the diff if inserting additional code and allows the block to be collapsed in an IDE.

return static_cast<int>(FloatComparisonMode::OrderedEqualNonSignaling);
}

case NI_SSE_CompareGreaterThan:
case NI_SSE_CompareScalarGreaterThan:
case NI_SSE2_CompareGreaterThan:
case NI_SSE2_CompareScalarGreaterThan:
case NI_SSE_CompareLessThan:
case NI_SSE_CompareScalarLessThan:
case NI_SSE2_CompareLessThan:
case NI_SSE2_CompareScalarLessThan:
case NI_AVX_CompareLessThan:
{
return static_cast<int>(FloatComparisonMode::OrderedLessThanSignaling);
}

case NI_SSE_CompareGreaterThanOrEqual:
case NI_SSE_CompareScalarGreaterThanOrEqual:
case NI_SSE2_CompareGreaterThanOrEqual:
case NI_SSE2_CompareScalarGreaterThanOrEqual:
case NI_SSE_CompareLessThanOrEqual:
case NI_SSE_CompareScalarLessThanOrEqual:
case NI_SSE2_CompareLessThanOrEqual:
case NI_SSE2_CompareScalarLessThanOrEqual:
case NI_AVX_CompareLessThanOrEqual:
{
return static_cast<int>(FloatComparisonMode::OrderedLessThanOrEqualSignaling);
}

case NI_SSE_CompareNotEqual:
case NI_SSE_CompareScalarNotEqual:
case NI_SSE2_CompareNotEqual:
case NI_SSE2_CompareScalarNotEqual:
case NI_AVX_CompareNotEqual:
{
return static_cast<int>(FloatComparisonMode::UnorderedNotEqualNonSignaling);
}

case NI_SSE_CompareNotGreaterThan:
case NI_SSE_CompareScalarNotGreaterThan:
case NI_SSE2_CompareNotGreaterThan:
case NI_SSE2_CompareScalarNotGreaterThan:
case NI_SSE_CompareNotLessThan:
case NI_SSE_CompareScalarNotLessThan:
case NI_SSE2_CompareNotLessThan:
case NI_SSE2_CompareScalarNotLessThan:
case NI_AVX_CompareNotLessThan:
{
return static_cast<int>(FloatComparisonMode::UnorderedNotLessThanSignaling);
}

case NI_SSE_CompareNotGreaterThanOrEqual:
case NI_SSE_CompareScalarNotGreaterThanOrEqual:
case NI_SSE2_CompareNotGreaterThanOrEqual:
case NI_SSE2_CompareScalarNotGreaterThanOrEqual:
case NI_SSE_CompareNotLessThanOrEqual:
case NI_SSE_CompareScalarNotLessThanOrEqual:
case NI_SSE2_CompareNotLessThanOrEqual:
case NI_SSE2_CompareScalarNotLessThanOrEqual:
case NI_AVX_CompareNotLessThanOrEqual:
{
return static_cast<int>(FloatComparisonMode::UnorderedNotLessThanOrEqualSignaling);
}

case NI_SSE_CompareOrdered:
case NI_SSE_CompareScalarOrdered:
case NI_SSE2_CompareOrdered:
case NI_SSE2_CompareScalarOrdered:
case NI_AVX_CompareOrdered:
{
return static_cast<int>(FloatComparisonMode::OrderedNonSignaling);
}

case NI_SSE_CompareUnordered:
case NI_SSE_CompareScalarUnordered:
case NI_SSE2_CompareUnordered:
case NI_SSE2_CompareScalarUnordered:
case NI_AVX_CompareUnordered:
{
return static_cast<int>(FloatComparisonMode::UnorderedNonSignaling);
}

case NI_SSE41_Ceiling:
case NI_SSE41_CeilingScalar:
case NI_SSE41_RoundToPositiveInfinity:
case NI_SSE41_RoundToPositiveInfinityScalar:
case NI_AVX_Ceiling:
case NI_AVX_RoundToPositiveInfinity:
{
return static_cast<int>(FloatRoundingMode::ToPositiveInfinity);
}

case NI_SSE41_Floor:
case NI_SSE41_FloorScalar:
case NI_SSE41_RoundToNegativeInfinity:
case NI_SSE41_RoundToNegativeInfinityScalar:
case NI_AVX_Floor:
case NI_AVX_RoundToNegativeInfinity:
{
return static_cast<int>(FloatRoundingMode::ToNegativeInfinity);
}

case NI_SSE41_RoundCurrentDirection:
case NI_SSE41_RoundCurrentDirectionScalar:
case NI_AVX_RoundCurrentDirection:
{
return static_cast<int>(FloatRoundingMode::CurrentDirection);
}

case NI_SSE41_RoundToNearestInteger:
case NI_SSE41_RoundToNearestIntegerScalar:
case NI_AVX_RoundToNearestInteger:
{
return static_cast<int>(FloatRoundingMode::ToNearestInteger);
}

case NI_SSE41_RoundToZero:
case NI_SSE41_RoundToZeroScalar:
case NI_AVX_RoundToZero:
{
return static_cast<int>(FloatRoundingMode::ToZero);
}

case NI_AVX_CompareGreaterThan:
{
return static_cast<int>(FloatComparisonMode::OrderedGreaterThanSignaling);
}

case NI_AVX_CompareGreaterThanOrEqual:
{
return static_cast<int>(FloatComparisonMode::OrderedGreaterThanOrEqualSignaling);
}

case NI_AVX_CompareNotGreaterThan:
{
return static_cast<int>(FloatComparisonMode::UnorderedNotGreaterThanSignaling);
}

case NI_AVX_CompareNotGreaterThanOrEqual:
{
return static_cast<int>(FloatComparisonMode::UnorderedNotGreaterThanOrEqualSignaling);
}

default:
{
return -1;
}
}
}
#endif

Expand Down
4 changes: 2 additions & 2 deletions src/coreclr/src/jit/hwintrinsiccodegenxarch.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1231,8 +1231,8 @@ void CodeGen::genBaseIntrinsic(GenTreeHWIntrinsic* node)
break;
}

case NI_Vector128_Zero:
case NI_Vector256_Zero:
case NI_Vector128_get_Zero:
case NI_Vector256_get_Zero:
{
assert(op1 == nullptr);
emit->emitIns_SIMD_R_R_R(ins, attr, targetReg, targetReg, targetReg);
Expand Down
Loading