Skip to content
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
6 changes: 3 additions & 3 deletions src/coreclr/jit/codegenarm64.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -3613,7 +3613,7 @@ void CodeGen::genCodeForCpObj(GenTreeBlk* cpObjNode)
// On ARM64, SIMD loads/stores provide 8-byte atomicity guarantees when aligned to 8 bytes.
regNumber tmpSimdReg1 = REG_NA;
regNumber tmpSimdReg2 = REG_NA;
if ((slots >= 4) && compiler->IsBaselineSimdIsaSupported())
if (slots >= 4)
{
tmpSimdReg1 = internalRegisters.Extract(cpObjNode, RBM_ALLFLOAT);
tmpSimdReg2 = internalRegisters.Extract(cpObjNode, RBM_ALLFLOAT);
Expand Down Expand Up @@ -3644,8 +3644,8 @@ void CodeGen::genCodeForCpObj(GenTreeBlk* cpObjNode)
// Copy at least two slots at a time
if (nonGcSlots >= 2)
{
// Do 4 slots at a time if SIMD is supported
if ((nonGcSlots >= 4) && compiler->IsBaselineSimdIsaSupported())
// Do 4 slots at a time with SIMD instructions
if (nonGcSlots >= 4)
{
// We need SIMD temp regs now
tmp1 = tmpSimdReg1;
Expand Down
2 changes: 1 addition & 1 deletion src/coreclr/jit/codegenxarch.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -3302,7 +3302,7 @@ void CodeGen::genCodeForInitBlkUnroll(GenTreeBlk* node)
// INITBLK zeroes a struct that contains GC pointers and can be observed by
// other threads (i.e. when dstAddr is not an address of a local).
// For example, this can happen when initializing a struct field of an object.
const bool canUse16BytesSimdMov = !node->IsOnHeapAndContainsReferences() && compiler->IsBaselineSimdIsaSupported();
const bool canUse16BytesSimdMov = !node->IsOnHeapAndContainsReferences();
const bool willUseSimdMov = canUse16BytesSimdMov && (size >= XMM_REGSIZE_BYTES);

if (!src->isContained())
Expand Down
57 changes: 30 additions & 27 deletions src/coreclr/jit/compiler.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1920,11 +1920,15 @@ void Compiler::compSetProcessor()
opts.compSupportsISAReported.Reset();
opts.compSupportsISAExactly.Reset();

// The VM will set the ISA flags depending on actual hardware support
// and any specified config switches specified by the user. The exception
// here is for certain "artificial ISAs" such as Vector64/128/256 where they
// don't actually exist. The JIT is in charge of adding those and ensuring
// the total sum of flags is still valid.
// The VM will set the ISA flags depending on actual hardware support and any
// config values specified by the user. Config may cause the VM to omit baseline
// ISAs from the supported set. We force their inclusion here so that JIT code
// can use them unconditionally, but we will honor the config when resolving
// managed HWIntrinsic methods.
//
// We also take care of adding the virtual vector ISAs (i.e. Vector64/128/256/512)
// here, based on the combination of hardware ISA support and config values.

#if defined(TARGET_XARCH)
// If the VM passed in a virtual vector ISA, it was done to communicate PreferredVectorBitWidth.
// No check is done for the validity of the value, since it will be clamped to max supported by
Expand Down Expand Up @@ -1955,10 +1959,14 @@ void Compiler::compSetProcessor()
!instructionSetFlags.HasInstructionSet(InstructionSet_Vector256) &&
!instructionSetFlags.HasInstructionSet(InstructionSet_Vector512));

if (instructionSetFlags.HasInstructionSet(InstructionSet_X86Base))
{
instructionSetFlags.AddInstructionSet(InstructionSet_Vector128);
}
// Ensure required baseline ISAs are supported in JIT code, even if not passed in by the VM.
instructionSetFlags.AddInstructionSet(InstructionSet_X86Base);
#ifdef TARGET_AMD64
instructionSetFlags.AddInstructionSet(InstructionSet_X86Base_X64);
#endif // TARGET_AMD64

// We can now add the virtual vector ISAs as appropriate. Vector128 is part of the required baseline.
instructionSetFlags.AddInstructionSet(InstructionSet_Vector128);

if (instructionSetFlags.HasInstructionSet(InstructionSet_AVX))
{
Expand All @@ -1970,11 +1978,15 @@ void Compiler::compSetProcessor()
instructionSetFlags.AddInstructionSet(InstructionSet_Vector512);
}
#elif defined(TARGET_ARM64)
if (instructionSetFlags.HasInstructionSet(InstructionSet_AdvSimd))
{
instructionSetFlags.AddInstructionSet(InstructionSet_Vector64);
instructionSetFlags.AddInstructionSet(InstructionSet_Vector128);
}
// Ensure required baseline ISAs are supported in JIT code, even if not passed in by the VM.
instructionSetFlags.AddInstructionSet(InstructionSet_ArmBase);
instructionSetFlags.AddInstructionSet(InstructionSet_ArmBase_Arm64);
instructionSetFlags.AddInstructionSet(InstructionSet_AdvSimd);
instructionSetFlags.AddInstructionSet(InstructionSet_AdvSimd_Arm64);

// Add virtual vector ISAs. These are both supported as part of the required baseline.
instructionSetFlags.AddInstructionSet(InstructionSet_Vector64);
instructionSetFlags.AddInstructionSet(InstructionSet_Vector128);
#endif // TARGET_ARM64

assert(instructionSetFlags.Equals(EnsureInstructionSetFlagsAreValid(instructionSetFlags)));
Expand Down Expand Up @@ -5956,11 +5968,8 @@ int Compiler::compCompile(CORINFO_MODULE_HANDLE classPtr,
}
}

if (JitConfig.EnableHWIntrinsic() != 0)
{
instructionSetFlags.AddInstructionSet(InstructionSet_ArmBase);
instructionSetFlags.AddInstructionSet(InstructionSet_AdvSimd);
}
instructionSetFlags.AddInstructionSet(InstructionSet_ArmBase);
instructionSetFlags.AddInstructionSet(InstructionSet_AdvSimd);

if (JitConfig.EnableArm64Aes() != 0)
{
Expand Down Expand Up @@ -6029,10 +6038,7 @@ int Compiler::compCompile(CORINFO_MODULE_HANDLE classPtr,
}
}

if (JitConfig.EnableHWIntrinsic() != 0)
{
instructionSetFlags.AddInstructionSet(InstructionSet_X86Base);
}
instructionSetFlags.AddInstructionSet(InstructionSet_X86Base);

if (JitConfig.EnableSSE3() != 0)
{
Expand Down Expand Up @@ -6142,10 +6148,7 @@ int Compiler::compCompile(CORINFO_MODULE_HANDLE classPtr,
instructionSetFlags.AddInstructionSet(InstructionSet_APX);
}
#elif defined(TARGET_RISCV64)
if (JitConfig.EnableHWIntrinsic() != 0)
{
instructionSetFlags.AddInstructionSet(InstructionSet_RiscV64Base);
}
instructionSetFlags.AddInstructionSet(InstructionSet_RiscV64Base);

if (JitConfig.EnableRiscV64Zba() != 0)
{
Expand Down
61 changes: 2 additions & 59 deletions src/coreclr/jit/compiler.h
Original file line number Diff line number Diff line change
Expand Up @@ -8928,46 +8928,6 @@ class Compiler
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
*/

bool IsBaselineSimdIsaSupported()
{
#ifdef FEATURE_SIMD
#if defined(TARGET_XARCH)
CORINFO_InstructionSet minimumIsa = InstructionSet_X86Base;
#elif defined(TARGET_ARM64)
CORINFO_InstructionSet minimumIsa = InstructionSet_AdvSimd;
#elif defined(TARGET_LOONGARCH64)
// TODO: supporting SIMD feature for LoongArch64.
assert(!"unimplemented yet on LA");
CORINFO_InstructionSet minimumIsa = 0;
#else
#error Unsupported platform
#endif // !TARGET_XARCH && !TARGET_ARM64 && !TARGET_LOONGARCH64

return compOpportunisticallyDependsOn(minimumIsa);
#else
return false;
#endif
}

#if defined(DEBUG)
bool IsBaselineSimdIsaSupportedDebugOnly()
{
#ifdef FEATURE_SIMD
#if defined(TARGET_XARCH)
CORINFO_InstructionSet minimumIsa = InstructionSet_X86Base;
#elif defined(TARGET_ARM64)
CORINFO_InstructionSet minimumIsa = InstructionSet_AdvSimd;
#else
#error Unsupported platform
#endif // !TARGET_XARCH && !TARGET_ARM64

return compIsaSupportedDebugOnly(minimumIsa);
#else
return false;
#endif // FEATURE_SIMD
}
#endif // DEBUG

bool isIntrinsicType(CORINFO_CLASS_HANDLE clsHnd)
{
return info.compCompHnd->isIntrinsicType(clsHnd);
Expand Down Expand Up @@ -9248,29 +9208,12 @@ class Compiler
{
return YMM_REGSIZE_BYTES;
}
else if (compOpportunisticallyDependsOn(InstructionSet_X86Base))
{
return XMM_REGSIZE_BYTES;
}
else
{
// TODO: We should be returning 0 here, but there are a number of
// places that don't quite get handled correctly in that scenario

return XMM_REGSIZE_BYTES;
}
#elif defined(TARGET_ARM64)
if (compOpportunisticallyDependsOn(InstructionSet_AdvSimd))
{
return FP_REGSIZE_BYTES;
}
else
{
// TODO: We should be returning 0 here, but there are a number of
// places that don't quite get handled correctly in that scenario

return FP_REGSIZE_BYTES;
}
return FP_REGSIZE_BYTES;
#else
assert(!"getMaxVectorByteLength() unimplemented on target arch");
unreached();
Expand Down Expand Up @@ -9470,7 +9413,7 @@ class Compiler
assert(size > 0);
var_types result = TYP_UNDEF;
#ifdef FEATURE_SIMD
if (IsBaselineSimdIsaSupported() && (roundDownSIMDSize(size) > 0))
if (roundDownSIMDSize(size) > 0)
{
return getSIMDTypeForSize(roundDownSIMDSize(size));
}
Expand Down
2 changes: 0 additions & 2 deletions src/coreclr/jit/decomposelongs.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1970,8 +1970,6 @@ GenTree* DecomposeLongs::DecomposeHWIntrinsicToScalar(LIR::Use& use, GenTreeHWIn
}
else
{
assert(m_compiler->compIsaSupportedDebugOnly(InstructionSet_X86Base));

GenTree* thirtyTwo = m_compiler->gtNewIconNode(32);
GenTree* shift = m_compiler->gtNewSimdBinOpNode(GT_RSZ, op1->TypeGet(), simdTmpVar, thirtyTwo,
node->GetSimdBaseJitType(), simdSize);
Expand Down
Loading
Loading