Porting from x86/x64 to ARM64EC or Pure Native ARM64#

This chapter describes the changes required to build existing x86 or x64 source code as ARM64EC, followed by the additional considerations that apply when targeting pure native ARM64.

Porting to ARM64EC#

The following sections describe header file usage, ARM64EC ABI requirements, minimum tooling requirements, predefined compilation variables, and the intrinsics support available for ARM64EC builds.

Header File Usage#

  • Avoid including x86/x64-specific headers such as xmmintrin.h.

  • Instead, use the generic umbrella header intrin.h, which is automatically included if you use windows.h.

ARM64EC ABI Requirements#

  • The ARM64EC ABI mandates that all function addresses be 4-byte aligned.

  • You may need to add align 4 directives to existing unported assembly code to meet this requirement.

Minimum Tooling Requirements#

  • Use at least:
    • Windows SDK 26100

    • Visual Studio 2022 version 17.14

  • These versions include recent fixes for ARM64EC and native ARM64 support.

Predefined Compilation Variables#

  • When compiling as ARM64EC, the compiler predefines _M_AMD64 and _M_ARM64EC.

  • It does not define _M_ARM64, even though the target is ARM-based.

Intrinsics Support#

  • SSE intrinsics are supported through the soft intrinsics library in the Windows SDK.

  • By default, AVX intrinsics and 256-bit types like __m256 will not compile.

Enhanced Intrinsics Library#

  • A more complete soft intrinsics library is available at:
  • This library:
    • Adds support for AVX and AVX2 intrinsics

    • Provides faster implementations of SSE intrinsics

    • Adds missing type support for 256-bit operations

Porting to Pure Native ARM64#

This process builds on the same rules used for ARM64EC porting, with a few additional considerations:

Compiler Settings#

  • Use the compiler switch /volatile:ms to enforce x86-style behavior for volatile variables. Without this, race conditions may occur due to relaxed memory ordering in native ARM64.

Intrinsics Support#

  • By default, soft intrinsics support is not enabled for native ARM64 builds.

  • To enable AVX and AVX2 intrinsics and improve SSE performance, use the enhanced soft intrinsics library.

Performance Impact of Store-Only Atomics#

  • Certain store-only atomic instructions such as STADD may execute as far atomics, leading to significant performance penalties.

  • This behavior differs from previous Windows on ARM CPUs, where such penalties were not observed.

  • A recommended alternative is to use the load versions of these atomics. For example, replace STADD with LDADD to avoid far atomic execution and improve performance.