diff --git a/src/coreclr/jit/importercalls.cpp b/src/coreclr/jit/importercalls.cpp index 603cd256109134..8a8c96c7cfe44c 100644 --- a/src/coreclr/jit/importercalls.cpp +++ b/src/coreclr/jit/importercalls.cpp @@ -4112,22 +4112,31 @@ GenTree* Compiler::impIntrinsic(CORINFO_CLASS_HANDLE clsHnd, } #endif // defined(TARGET_ARM64) || defined(TARGET_RISCV64) -#if defined(TARGET_XARCH) || defined(TARGET_ARM64) || defined(TARGET_RISCV64) +#if defined(TARGET_64BIT) || defined(TARGET_X86) // TODO-ARM-CQ: reenable treating InterlockedCmpXchg32 operation as intrinsic case NI_System_Threading_Interlocked_CompareExchange: { +#if defined(TARGET_LOONGARCH64) + // GT_CMPXCHG is NYI in lsraloongarch64 + mustExpand = false; + break; +#endif + var_types retType = JITtype2varType(sig->retType); if (genTypeSize(retType) > TARGET_POINTER_SIZE) { break; } -#if !defined(TARGET_XARCH) && !defined(TARGET_ARM64) +#if defined(TARGET_RISCV64) + // CAS for small types is natively supported starting with the Zabha extension; however, + // hardware support for RVA23 profile is not available at the time of writing. else if (genTypeSize(retType) < 4) { + mustExpand = false; break; } -#endif // !defined(TARGET_XARCH) && !defined(TARGET_ARM64) +#endif // defined(TARGET_RISCV64) if ((retType == TYP_REF) && (impStackTop(1).val->IsIntegralConst(0) || impStackTop(1).val->IsIconHandle(GTF_ICON_OBJ_HDL))) @@ -4158,18 +4167,27 @@ GenTree* Compiler::impIntrinsic(CORINFO_CLASS_HANDLE clsHnd, case NI_System_Threading_Interlocked_Exchange: case NI_System_Threading_Interlocked_ExchangeAdd: { +#if defined(TARGET_LOONGARCH64) + // GT_XADD and GT_XCHG are NYI in lsraloongarch64 + mustExpand = false; + break; +#endif + var_types retType = JITtype2varType(sig->retType); if (genTypeSize(retType) > TARGET_POINTER_SIZE) { break; } -#if !defined(TARGET_XARCH) && !defined(TARGET_ARM64) +#if defined(TARGET_RISCV64) + // CAS for small types is natively supported starting with the Zabha extension; however, + // hardware support for RVA23 profile is not available at the time of writing. else if (genTypeSize(retType) < 4) { + mustExpand = false; break; } -#endif // !defined(TARGET_XARCH) && !defined(TARGET_ARM64) +#endif // defined(TARGET_RISCV64) if ((retType == TYP_REF) && (impStackTop().val->IsIntegralConst(0) || impStackTop().val->IsIconHandle(GTF_ICON_OBJ_HDL))) @@ -4199,7 +4217,7 @@ GenTree* Compiler::impIntrinsic(CORINFO_CLASS_HANDLE clsHnd, callType, op1, op2); break; } -#endif // defined(TARGET_XARCH) || defined(TARGET_ARM64) || defined(TARGET_RISCV64) +#endif // defined(TARGET_64BIT) || defined(TARGET_X86) case NI_System_Threading_Interlocked_MemoryBarrier: {