Skip to content
Open
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
80 changes: 20 additions & 60 deletions src/coreclr/jit/assertionprop.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -272,8 +272,27 @@ bool IntegralRange::Contains(int64_t value) const
case GT_HWINTRINSIC:
{
GenTreeHWIntrinsic* hwintrinsic = node->AsHWIntrinsic();
NamedIntrinsic id = hwintrinsic->GetHWIntrinsicId();

switch (hwintrinsic->GetHWIntrinsicId())
if (HWIntrinsicInfo::ReturnsBoolean(id))
{
// A boolean [0, 1]
return {SymbolicIntegerValue::Zero, SymbolicIntegerValue::One};
}

if (HWIntrinsicInfo::ReturnsScalarT(id))
{
// We are extracting a value of the base types width and sign
var_types simdBaseType = hwintrinsic->GetSimdBaseType();

if (varTypeIsSmall(simdBaseType))
{
rangeType = simdBaseType;
}
break;
}

switch (id)
{
#if defined(TARGET_XARCH)
case NI_Vector256_ExtractMostSignificantBits:
Expand Down Expand Up @@ -303,65 +322,6 @@ bool IntegralRange::Contains(int64_t value) const
break;
}

#if defined(TARGET_XARCH)
case NI_Vector256_op_Equality:
case NI_Vector256_op_Inequality:
case NI_Vector512_op_Equality:
case NI_Vector512_op_Inequality:
case NI_X86Base_CompareScalarOrderedEqual:
case NI_X86Base_CompareScalarOrderedGreaterThan:
case NI_X86Base_CompareScalarOrderedGreaterThanOrEqual:
case NI_X86Base_CompareScalarOrderedLessThan:
case NI_X86Base_CompareScalarOrderedLessThanOrEqual:
case NI_X86Base_CompareScalarOrderedNotEqual:
case NI_X86Base_CompareScalarUnorderedEqual:
case NI_X86Base_CompareScalarUnorderedGreaterThan:
case NI_X86Base_CompareScalarUnorderedGreaterThanOrEqual:
case NI_X86Base_CompareScalarUnorderedLessThan:
case NI_X86Base_CompareScalarUnorderedLessThanOrEqual:
case NI_X86Base_CompareScalarUnorderedNotEqual:
case NI_X86Base_TestC:
case NI_X86Base_TestNotZAndNotC:
case NI_X86Base_TestZ:
case NI_AVX_TestC:
case NI_AVX_TestNotZAndNotC:
case NI_AVX_TestZ:
#elif defined(TARGET_ARM64)
case NI_Vector64_op_Equality:
case NI_Vector64_op_Inequality:
#endif
case NI_Vector128_op_Equality:
case NI_Vector128_op_Inequality:
{
// A boolean [0, 1]
return {SymbolicIntegerValue::Zero, SymbolicIntegerValue::One};
}

#if defined(TARGET_XARCH)
case NI_Vector256_GetElement:
case NI_Vector256_ToScalar:
case NI_Vector512_GetElement:
case NI_Vector512_ToScalar:
case NI_X86Base_Extract:
case NI_X86Base_X64_Extract:
#elif defined(TARGET_ARM64)
case NI_Vector64_GetElement:
case NI_Vector64_ToScalar:
case NI_AdvSimd_Extract:
#endif
case NI_Vector128_GetElement:
case NI_Vector128_ToScalar:
{
// We are extracting a value of the base types width and sign
var_types simdBaseType = hwintrinsic->GetSimdBaseType();

if (varTypeIsSmall(simdBaseType))
{
rangeType = simdBaseType;
}
break;
}

#if defined(TARGET_XARCH)
case NI_AVX2_LeadingZeroCount:
case NI_AVX2_TrailingZeroCount:
Expand Down
26 changes: 22 additions & 4 deletions src/coreclr/jit/hwintrinsic.h
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@ enum HWIntrinsicCategory : uint8_t
#else
#error Unsupported platform
#endif
enum HWIntrinsicFlag : unsigned int
enum HWIntrinsicFlag : uint64_t
{
HW_Flag_NoFlag = 0,

Expand Down Expand Up @@ -258,6 +258,12 @@ enum HWIntrinsicFlag : unsigned int
HW_Flag_FmaIntrinsic = 0x40000000,

HW_Flag_CanBenefitFromConstantProp = 0x80000000,

// The intrinsic returns a boolean (TYP_INT range [0, 1]).
HW_Flag_ReturnsBoolean = 0x100000000,

// The intrinsic extracts and returns a scalar value of the SIMD base type.
HW_Flag_ReturnsScalarT = 0x200000000,
};

#if defined(TARGET_XARCH)
Expand Down Expand Up @@ -511,11 +517,11 @@ struct TernaryLogicInfo

struct HWIntrinsicInfo
{
// 32-bit: 36-bytes (36 + 0 trailing padding)
// 64-bit: 40-bytes (40 + 0 trailing padding)
// 32-bit: 40-bytes (40 + 0 trailing padding)
// 64-bit: 48-bytes (48 + 0 trailing padding)

const char* name; // 4 or 8-bytes
HWIntrinsicFlag flags; // 4-bytes
HWIntrinsicFlag flags; // 8-bytes
NamedIntrinsic id; // 2-bytes
uint16_t ins[10]; // 10 * 2-bytes
uint8_t isa; // 1-byte
Expand Down Expand Up @@ -718,6 +724,18 @@ struct HWIntrinsicInfo
#endif
}

static bool ReturnsBoolean(NamedIntrinsic id)
{
HWIntrinsicFlag flags = lookupFlags(id);
return (flags & HW_Flag_ReturnsBoolean) != 0;
}

static bool ReturnsScalarT(NamedIntrinsic id)
{
HWIntrinsicFlag flags = lookupFlags(id);
return (flags & HW_Flag_ReturnsScalarT) != 0;
}

#if defined(TARGET_XARCH)
static bool AvxOnlyCompatible(NamedIntrinsic id)
{
Expand Down
Loading
Loading