Skip to content

Commit

Permalink
Ensure that TYP_SIMD16 and TYP_SIMD32 don't force mask usage unnecess…
Browse files Browse the repository at this point in the history
…arily
  • Loading branch information
tannergooding committed Dec 7, 2024
1 parent ada38db commit f9088fd
Show file tree
Hide file tree
Showing 3 changed files with 344 additions and 100 deletions.
11 changes: 5 additions & 6 deletions src/coreclr/jit/hwintrinsic.h
Original file line number Diff line number Diff line change
Expand Up @@ -546,12 +546,11 @@ struct HWIntrinsicInfo
static bool isScalarIsa(CORINFO_InstructionSet isa);

#ifdef TARGET_XARCH
static bool isAVX2GatherIntrinsic(NamedIntrinsic id);
static FloatComparisonMode lookupFloatComparisonModeForSwappedArgs(FloatComparisonMode comparison);
static NamedIntrinsic lookupIdForFloatComparisonMode(NamedIntrinsic intrinsic,
FloatComparisonMode comparison,
var_types simdBaseType,
unsigned simdSize);
static bool isAVX2GatherIntrinsic(NamedIntrinsic id);
static NamedIntrinsic lookupIdForFloatComparisonMode(NamedIntrinsic intrinsic,
FloatComparisonMode comparison,
var_types simdBaseType,
unsigned simdSize);
#endif

// Member lookup
Expand Down
102 changes: 8 additions & 94 deletions src/coreclr/jit/hwintrinsicxarch.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -473,95 +473,6 @@ bool HWIntrinsicInfo::isAVX2GatherIntrinsic(NamedIntrinsic id)
}
}

//------------------------------------------------------------------------
// lookupFloatComparisonModeForSwappedArgs: Get the floating-point comparison
// mode to use when the operands are swapped.
//
// Arguments:
// comparison -- The comparison mode used for (op1, op2)
//
// Return Value:
// The comparison mode to use for (op2, op1)
//
FloatComparisonMode HWIntrinsicInfo::lookupFloatComparisonModeForSwappedArgs(FloatComparisonMode comparison)
{
switch (comparison)
{
// These comparison modes are the same even if the operands are swapped

case FloatComparisonMode::OrderedEqualNonSignaling:
return FloatComparisonMode::OrderedEqualNonSignaling;
case FloatComparisonMode::UnorderedNonSignaling:
return FloatComparisonMode::UnorderedNonSignaling;
case FloatComparisonMode::UnorderedNotEqualNonSignaling:
return FloatComparisonMode::UnorderedNotEqualNonSignaling;
case FloatComparisonMode::OrderedNonSignaling:
return FloatComparisonMode::OrderedNonSignaling;
case FloatComparisonMode::UnorderedEqualNonSignaling:
return FloatComparisonMode::UnorderedEqualNonSignaling;
case FloatComparisonMode::OrderedFalseNonSignaling:
return FloatComparisonMode::OrderedFalseNonSignaling;
case FloatComparisonMode::OrderedNotEqualNonSignaling:
return FloatComparisonMode::OrderedNotEqualNonSignaling;
case FloatComparisonMode::UnorderedTrueNonSignaling:
return FloatComparisonMode::UnorderedTrueNonSignaling;
case FloatComparisonMode::OrderedEqualSignaling:
return FloatComparisonMode::OrderedEqualSignaling;
case FloatComparisonMode::UnorderedSignaling:
return FloatComparisonMode::UnorderedSignaling;
case FloatComparisonMode::UnorderedNotEqualSignaling:
return FloatComparisonMode::UnorderedNotEqualSignaling;
case FloatComparisonMode::OrderedSignaling:
return FloatComparisonMode::OrderedSignaling;
case FloatComparisonMode::UnorderedEqualSignaling:
return FloatComparisonMode::UnorderedEqualSignaling;
case FloatComparisonMode::OrderedFalseSignaling:
return FloatComparisonMode::OrderedFalseSignaling;
case FloatComparisonMode::OrderedNotEqualSignaling:
return FloatComparisonMode::OrderedNotEqualSignaling;
case FloatComparisonMode::UnorderedTrueSignaling:
return FloatComparisonMode::UnorderedTrueSignaling;

// These comparison modes need a different mode if the operands are swapped

case FloatComparisonMode::OrderedLessThanSignaling:
return FloatComparisonMode::OrderedGreaterThanSignaling;
case FloatComparisonMode::OrderedLessThanOrEqualSignaling:
return FloatComparisonMode::OrderedGreaterThanOrEqualSignaling;
case FloatComparisonMode::UnorderedNotLessThanSignaling:
return FloatComparisonMode::UnorderedNotGreaterThanSignaling;
case FloatComparisonMode::UnorderedNotLessThanOrEqualSignaling:
return FloatComparisonMode::UnorderedNotGreaterThanOrEqualSignaling;
case FloatComparisonMode::UnorderedNotGreaterThanOrEqualSignaling:
return FloatComparisonMode::UnorderedNotLessThanOrEqualSignaling;
case FloatComparisonMode::UnorderedNotGreaterThanSignaling:
return FloatComparisonMode::UnorderedNotLessThanSignaling;
case FloatComparisonMode::OrderedGreaterThanOrEqualSignaling:
return FloatComparisonMode::OrderedLessThanOrEqualSignaling;
case FloatComparisonMode::OrderedGreaterThanSignaling:
return FloatComparisonMode::OrderedLessThanSignaling;
case FloatComparisonMode::OrderedLessThanNonSignaling:
return FloatComparisonMode::OrderedGreaterThanNonSignaling;
case FloatComparisonMode::OrderedLessThanOrEqualNonSignaling:
return FloatComparisonMode::OrderedGreaterThanOrEqualNonSignaling;
case FloatComparisonMode::UnorderedNotLessThanNonSignaling:
return FloatComparisonMode::UnorderedNotGreaterThanNonSignaling;
case FloatComparisonMode::UnorderedNotLessThanOrEqualNonSignaling:
return FloatComparisonMode::UnorderedNotGreaterThanOrEqualNonSignaling;
case FloatComparisonMode::UnorderedNotGreaterThanOrEqualNonSignaling:
return FloatComparisonMode::UnorderedNotLessThanOrEqualNonSignaling;
case FloatComparisonMode::UnorderedNotGreaterThanNonSignaling:
return FloatComparisonMode::UnorderedNotLessThanNonSignaling;
case FloatComparisonMode::OrderedGreaterThanOrEqualNonSignaling:
return FloatComparisonMode::OrderedLessThanOrEqualNonSignaling;
case FloatComparisonMode::OrderedGreaterThanNonSignaling:
return FloatComparisonMode::OrderedLessThanNonSignaling;

default:
unreached();
}
}

//------------------------------------------------------------------------
// lookupIdForFloatComparisonMode: Get the intrinsic ID to use for a given float comparison mode
//
Expand Down Expand Up @@ -4858,8 +4769,6 @@ GenTree* Compiler::impSpecialIntrinsic(NamedIntrinsic intrinsic,

op3 = impPopStack().val;
op3 = addRangeCheckIfNeeded(intrinsic, op3, immLowerBound, immUpperBound);
op2 = impSIMDPopStack();
op1 = impSIMDPopStack();

if (op3->IsCnsIntOrI())
{
Expand All @@ -4869,20 +4778,25 @@ GenTree* Compiler::impSpecialIntrinsic(NamedIntrinsic intrinsic,

if (id != intrinsic)
{
intrinsic = id;
op3 = nullptr;
return impSpecialIntrinsic(id, clsHnd, method, sig R2RARG(&emptyEntryPoint),
simdBaseJitType, retType, simdSize, mustExpand);
}
}

op2 = impSIMDPopStack();
op1 = impSIMDPopStack();

if (op3 == nullptr)
{
retNode = gtNewSimdHWIntrinsicNode(retType, op1, op2, intrinsic, simdBaseJitType, simdSize);
}
else
{
retNode = gtNewSimdHWIntrinsicNode(retType, op1, op2, op3, intrinsic, simdBaseJitType, simdSize);

}

retNode = gtNewSimdHWIntrinsicNode(retType, op1, op2, op3, intrinsic, simdBaseJitType, simdSize);

if (retType == TYP_MASK)
{
retType = getSIMDTypeForSize(simdSize);
Expand Down
Loading

0 comments on commit f9088fd

Please sign in to comment.