Skip to content

Commit dd05959

Browse files
Ensure partial Vector256 acceleration is still possible on AVX only hardware (#73720)
* Ensure that Vector256 APIs exposed in .NET Core 3.1 remain accelerated in .NET 7 * Ensure new Vector256 APIs that are trivially limited to Avx only are accelerated
1 parent 77d9533 commit dd05959

File tree

3 files changed

+61
-49
lines changed

3 files changed

+61
-49
lines changed

src/coreclr/jit/hwintrinsic.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -383,8 +383,8 @@ NamedIntrinsic HWIntrinsicInfo::lookupId(Compiler* comp,
383383
NamedIntrinsic ni = intrinsicInfo.id;
384384

385385
#if defined(TARGET_XARCH)
386-
// on AVX1-only CPUs we only support NI_Vector256_Create intrinsic in Vector256
387-
if (isLimitedVector256Isa && (ni != NI_Vector256_Create))
386+
// on AVX1-only CPUs we only support a subset of intrinsics in Vector256
387+
if (isLimitedVector256Isa && !AvxOnlyCompatible(ni))
388388
{
389389
return NI_Illegal;
390390
}

src/coreclr/jit/hwintrinsic.h

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -147,7 +147,11 @@ enum HWIntrinsicFlag : unsigned int
147147
// Returns Per-Element Mask
148148
// the intrinsic returns a vector containing elements that are either "all bits set" or "all bits clear"
149149
// this output can be used as a per-element mask
150-
HW_Flag_ReturnsPerElementMask = 0x20000
150+
HW_Flag_ReturnsPerElementMask = 0x20000,
151+
152+
// AvxOnlyCompatible
153+
// the intrinsic can be used on hardware with AVX but not AVX2 support
154+
HW_Flag_AvxOnlyCompatible = 0x40000,
151155

152156
#elif defined(TARGET_ARM64)
153157
// The intrinsic has an immediate operand
@@ -658,6 +662,14 @@ struct HWIntrinsicInfo
658662
#endif
659663
}
660664

665+
#if defined(TARGET_XARCH)
666+
static bool AvxOnlyCompatible(NamedIntrinsic id)
667+
{
668+
HWIntrinsicFlag flags = lookupFlags(id);
669+
return (flags & HW_Flag_AvxOnlyCompatible) != 0;
670+
}
671+
#endif
672+
661673
static bool BaseTypeFromFirstArg(NamedIntrinsic id)
662674
{
663675
HWIntrinsicFlag flags = lookupFlags(id);

0 commit comments

Comments
 (0)