# SSE4

**SSE4**（Streaming SIMD Extensions 4，[流式 SIMD 扩展](https://www.edgepedia.org/zh/streaming-simd-extensions) 4）是 x86 SIMD 指令集的扩展，由英特尔（Intel）于 2007 年公布，为随 SSE 引入的 128 位 XMM 寄存器模型新增 54 条指令。英特尔将该扩展分为两部分：SSE4.1 包含 47 条指令，面向媒体、成像和 3D 工作负载；SSE4.2 包含 7 条指令，聚焦于字符串与文本处理、打包四字比较，以及硬件 CRC 和位计数加速。<sup>[1](https://software.intel.com/content/dam/www/public/us/en/documents/manuals/64-ia-32-architectures-software-developers-manual.pdf)</sup> 47 条 SSE4.1 指令首先出现在基于 Penryn 微架构的 45 纳米英特尔处理器中，该微架构是 Core 微架构的继任者；7 条指令的 SSE4.2 子集则随 Nehalem 微架构问世。<sup>[2](https://community.intel.com/t5/Intel-ISA-Extensions/SSE-4-2-on-which-processors/td-p/847903)</sup>

| 关键事实 | 详情 |
|---|---|
| 总规模 | 54 条新指令：SSE4.1 中 47 条，SSE4.2 中 7 条<sup>[1](https://software.intel.com/content/dam/www/public/us/en/documents/manuals/64-ia-32-architectures-software-developers-manual.pdf)</sup> |
| 首次硬件 | SSE4.1 见于 45 纳米 Penryn 处理器；SSE4.2 见于 Nehalem 处理器<sup>[2](https://community.intel.com/t5/Intel-ISA-Extensions/SSE-4-2-on-which-processors/td-p/847903)</sup> |
| CPUID 标志 | SSE4.1 = CPUID.01H:ECX 第 19 位；SSE4.2 = ECX 第 20 位；POPCNT = ECX 第 23 位<sup>[3](https://www.intel.com/content/dam/develop/external/us/en/documents/d9156103-705230.pdf)</sup> |
| SSE4.1 重点 | 媒体、成像和 3D 工作负载；编译器向量化；打包双字计算<sup>[1](https://software.intel.com/content/dam/www/public/us/en/documents/manuals/64-ia-32-architectures-software-developers-manual.pdf)</sup> |
| SSE4.2 重点 | 字符串与文本处理（PCMPESTRI/PCMPESTRM/PCMPISTRI/PCMPISTRM）、PCMPGTQ、CRC32、POPCNT<sup>[4](https://www.intel.com/content/dam/doc/manual/64-ia-32-architectures-optimization-manual.pdf)</sup> |
| 区别于 | AMD 的 SSE4A，后者是独立的小型扩展，新增 EXTRQ、INSERTQ、MOVNTSS 和 MOVNTSD<sup>[5](https://docs.amd.com/api/khub/documents/68GKiN0gMEd6bMddsmhPwg/content)</sup> |

## SSE4.1

SSE4.1 旨在提升媒体、成像和 3D 工作负载的性能。它新增的指令改进了编译器向量化，显著增强了对打包双字（32 位整数）计算的支持，并提供了一条加载提示指令，可在从不可缓存的写合并内存读取时提高内存吞吐量。<sup>[1](https://software.intel.com/content/dam/www/public/us/en/documents/manuals/64-ia-32-architectures-software-developers-manual.pdf)</sup> 英特尔按功能将 47 条指令分组：两条打包双字乘法（PMULLD 返回四个有符号 32 位乘法结果各自的低 32 位）、两条带输入和输出选择的浮点点积（DPPS 和 DPPD）、一条流式提示加载、六条打包混合指令、八条打包整数 MIN/MAX 指令、四条带可选舍入模式和精度异常覆盖的浮点舍入指令、七条数据插入与提取指令、十二条打包整数格式转换指令，以及分别用于小块绝对差求和、水平搜索、掩码比较、打包四字相等比较（PCMPEQQ）和带无符号饱和的双字打包（PACKUSDW）的各一条指令。<sup>[1](https://software.intel.com/content/dam/www/public/us/en/documents/manuals/64-ia-32-architectures-software-developers-manual.pdf)</sup>

**混合。** 六条指令处理条件元素选择：BLENDPS、BLENDPD、BLENDVPS、BLENDVPD、PBLENDVB 和 PBLENDW。混合操作有条件地将数据元素从源操作数复制到目标中的相同元素位置，英特尔表示，一条 SSE4.1 混合指令通常可以替代早期架构上 2 到 4 条操作的序列。可变混合（BLENDVPS、BLENDVPD、PBLENDVB）使用存储在隐式 XMM 寄存器 XMM0 中的控制位，每个字段的最高位即符号位充当选择器。<sup>[6](https://cdrdv2-public.intel.com/868137/325462-089-sdm-vol-1-2abcd-3abcd-4.pdf)</sup> 立即数控制形式基于立即数掩码从两个源中选择单精度数或双精度数，可变形式则基于 XMM0 中的掩码进行选择。<sup>[7](https://instructionsets.com/x86/extensions/sse4-1/)</sup>

SSE4.1 指令操作 XMM 寄存器，其编程方式类似于 SSE、SSE2、SSE3 和 SSSE3 的 128 位整数与浮点 SIMD 指令；SSE4.1 不提供操作 MMX 寄存器的 64 位整数 SIMD 指令。<sup>[1](https://software.intel.com/content/dam/www/public/us/en/documents/manuals/64-ia-32-architectures-software-developers-manual.pdf)</sup>

## SSE4.2

SSE4.2 新增 7 条指令。其中五条操作 XMM 寄存器：四条字符串与文本处理指令，以及一条打包四字比较指令 PCMPGTQ，后者对打包整数四字执行大于比较，扩展了 SSE4.1 引入的 128 位整数 SIMD 能力。其余两条是面向应用的加速指令，操作通用寄存器：CRC32 为循环冗余校验提供硬件加速，POPCNT 统计置位位数并加速位模式搜索。<sup>[3](https://www.intel.com/content/dam/develop/external/us/en/documents/d9156103-705230.pdf)</sup>

**字符串与文本指令。** PCMPESTRI、PCMPESTRM、PCMPISTRI 和 PCMPISTRM 加速字符串与文本处理、词法分析，以及非结构化或结构化文本数据的解析。每条指令最多对两个各不超过 16 字节的文本片段执行 256 次比较操作，以字节或字为元素，可带符号或无符号，由立即数字节配置。简单用途包括确定字符串长度、直接比较字符串、处理大小写、处理分隔符与标记、定位词边界以及定位子串匹配；英特尔指出，巧妙运用这些指令可以加速 XML 解析和模式验证。<sup>[4](https://www.intel.com/content/dam/doc/manual/64-ia-32-architectures-optimization-manual.pdf)</sup> 立即数操作数选择比较类型（任意相等、范围、逐项相等或有序相等）、极性变换，以及结果是以 ECX 中的索引还是 XMM0 中的掩码返回。显式长度形式从 EDX:EAX 寄存器对中获取片段长度，隐式长度形式则使用空字符终止。<sup>[4](https://www.intel.com/content/dam/doc/manual/64-ia-32-architectures-optimization-manual.pdf)</sup> 与大多数其他 128 位 SIMD 指令不同，这四条指令不对内存操作数执行对齐检查，从而简化了非对齐数据的文本处理。<sup>[3](https://www.intel.com/content/dam/develop/external/us/en/documents/d9156103-705230.pdf)</sup>

**CRC32。** CRC32 指令使用多项式 0x11EDC6F41（即 CRC32C 多项式）累加 CRC32 值，从目标寄存器中的初始值开始，以反射位序处理源操作数。软件通过在目标中保留上一次结果并用新输入数据再次执行该指令，从而在长数据流上累加。<sup>[3](https://www.intel.com/content/dam/develop/external/us/en/documents/d9156103-705230.pdf)</sup> 英特尔的优化手册报告称，对于中小规模的字符串，基于硬件 CRC32 指令构建的哈希函数可比传统的乘法移位软件哈希快一倍。<sup>[4](https://www.intel.com/content/dam/doc/manual/64-ia-32-architectures-optimization-manual.pdf)</sup>

## 检测与软件支持

软件在使用 SSE4 指令前必须验证支持情况，因为在不具备该特性的处理器上执行这些指令会引发无效操作码故障。使用 CPUID 叶 1 时，SSE4.1 支持由 ECX 第 19 位指示，SSE4.2 字符串、PCMPGTQ 和 CRC32 支持由第 20 位指示，POPCNT 由第 23 位指示。<sup>[3](https://www.intel.com/content/dam/develop/external/us/en/documents/d9156103-705230.pdf)</sup> POPCNT 有独立的功能位，因此稳健的软件会单独检查它，而不是假定只要存在 SSE4.2 就必然存在 POPCNT。<sup>[8](https://tommesani.com/sse4-2-the-simd-extension-focused-on-strings-crc-and-64-bit-comparisons/)</sup> [操作系统](https://www.edgepedia.org/zh/operating-system)支持要求与 SSE 相同，CRC32 和 POPCNT 除正常的 Intel 64 要求外无需特殊的操作系统启用。<sup>[3](https://www.intel.com/content/dam/develop/external/us/en/documents/d9156103-705230.pdf)</sup>

编译器通过开关和内建函数暴露该扩展。GCC 的 `-msse4.1` 启用 MMX、SSE、SSE2、SSE3、SSSE3 和 SSE4.1 的内建函数与代码生成；`-msse4.2` 增加 SSE4.2；`-msse4` 同时启用 SSE4.1 和 SSE4.2，而单独的 `-msse4a` 选项控制 AMD 的 SSE4A，不受 `-msse4` 或 `-mno-sse4` 影响。<sup>[9](https://gcc.gnu.org/onlinedocs/gcc/x86-Options.html)</sup> GCC 还提供运行时内建函数 `__builtin_cpu_supports`，对包括 `sse4.1` 和 `sse4.2` 在内的特性返回正整数。<sup>[10](https://gcc.gnu.org/onlinedocs/gcc/x86-Built-in-Functions.html)</sup> 微软的 `__cpuid` 内建函数在 Windows 上暴露相同的 CPUID 信息，较新的 `__check_isa_support` 内建函数提供更快的动态检查，其中包含 `__IA_SUPPORT_SSE42` 特性值。<sup>[11](https://learn.microsoft.com/en-us/cpp/intrinsics/cpuid-cpuidex?view=msvc-170)</sup><sup> • </sup><sup>[12](https://learn.microsoft.com/en-us/cpp/intrinsics/check-isa-arch-support?view=msvc-160)</sup> 执行运行时 CPU 检测的应用程序必须在编译检测代码时不使用启用该 ISA 的开关，否则编译器可能在使用这些开关编译的任何文件中生成扩展指令。<sup>[9](https://gcc.gnu.org/onlinedocs/gcc/x86-Options.html)</sup>

## SSE4 与 AMD SSE4A 之别

SSE4.1 和 SSE4.2 不应与 AMD 的 SSE4A 混淆，后者是对 SSE 指令集的独立小型扩展，新增 EXTRQ、INSERTQ、MOVNTSS 和 MOVNTSD 指令。<sup>[5](https://docs.amd.com/api/khub/documents/68GKiN0gMEd6bMddsmhPwg/content)</sup> SSE4A 支持由不同的 CPUID 标志报告，即叶 8000_0001h 的 ECX 第 6 位。<sup>[13](https://docs.amd.com/api/khub/documents/sD1_QL~h4Afq2_tvzxqqSQ/content)</sup> 两个扩展不共享任何指令，编译器选项也独立对待它们。<sup>[9](https://gcc.gnu.org/onlinedocs/gcc/x86-Options.html)</sup>

## 后续历史

SSE4.1 和 SSE4.2 仍然是后续 x86 扩展所构建的基础的一部分：GCC 的 `-mavx`、`-mavx2` 和 AVX-512 选项除较新的指令集外，都会启用从 MMX 到 SSE4.2 的完整链条。<sup>[9](https://gcc.gnu.org/onlinedocs/gcc/x86-Options.html)</sup> 尤其是 CRC32 指令，其寿命超出了它问世时的 128 位 SIMD 语境；[Linux 内核](https://www.edgepedia.org/zh/linux-kernel)的 CRC32c 实现在支持该指令的处理器上使用 SSE4.2 硬件指令，该指令的编码后来也随较新的扩展一起被纳入 AVX 时代的编程参考手册。<sup>[14](https://cateee.net/lkddb/web-lkddb/CRYPTO_CRC32C_INTEL.html)</sup><sup> • </sup><sup>[15](https://cdrdv2-public.intel.com/843860/architecture-instruction-set-extensions-programming-reference-dec-24.pdf)</sup>

## References

1. [Intel 64 and IA-32 Architectures Software Developer's Manual, Instruction Set Summary, Section 5.9 SSE4 Instructions](https://software.intel.com/content/dam/www/public/us/en/documents/manuals/64-ia-32-architectures-software-developers-manual.pdf)
2. [SSE 4.2 on which processors? Intel Community](https://community.intel.com/t5/Intel-ISA-Extensions/SSE-4-2-on-which-processors/td-p/847903)
3. [SSE4 Instruction Set Programming Reference (Intel)](https://www.intel.com/content/dam/develop/external/us/en/documents/d9156103-705230.pdf)
4. [Intel 64 and IA-32 Architectures Optimization Reference Manual, Chapter 10: SSE4.2 and SIMD Programming for Text-Processing/Lexing/Parsing](https://www.intel.com/content/dam/doc/manual/64-ia-32-architectures-optimization-manual.pdf)
5. [AMD64 Architecture Programmer's Manual, Volumes 1-5, Glossary](https://docs.amd.com/api/khub/documents/68GKiN0gMEd6bMddsmhPwg/content)
6. [Intel 64 and IA-32 Architectures Software Developer's Manual, Section 12.10.4 Packed Blending Instructions](https://cdrdv2-public.intel.com/868137/325462-089-sdm-vol-1-2abcd-3abcd-4.pdf)
7. [SSE4.1 Instructions, x86 ISA Database](https://instructionsets.com/x86/extensions/sse4-1/)
8. [SSE4.2: the SIMD extension focused on strings, CRC, and 64-bit comparisons, Stefano Tommesani](https://tommesani.com/sse4-2-the-simd-extension-focused-on-strings-crc-and-64-bit-comparisons/)
9. [x86 Options, Using the GNU Compiler Collection (GCC)](https://gcc.gnu.org/onlinedocs/gcc/x86-Options.html)
10. [x86 Built-in Functions, Using the GNU Compiler Collection (GCC)](https://gcc.gnu.org/onlinedocs/gcc/x86-Built-in-Functions.html)
11. [__cpuid, __cpuidex, Microsoft Learn](https://learn.microsoft.com/en-us/cpp/intrinsics/cpuid-cpuidex?view=msvc-170)
12. [__check_isa_support, __check_arch_support, Microsoft Learn](https://learn.microsoft.com/en-us/cpp/intrinsics/check-isa-arch-support?view=msvc-160)
13. [AMD64 Architecture Programmer's Manual, Volume 2: System Programming, CPUID table](https://docs.amd.com/api/khub/documents/sD1_QL~h4Afq2_tvzxqqSQ/content)
14. [CONFIG_CRYPTO_CRC32C_INTEL: CRC32c (SSE4.2/PCLMULQDQ), Linux Kernel Driver DataBase](https://cateee.net/lkddb/web-lkddb/CRYPTO_CRC32C_INTEL.html)
15. [Intel Architecture Instruction Set Extensions Programming Reference](https://cdrdv2-public.intel.com/843860/architecture-instruction-set-extensions-programming-reference-dec-24.pdf)

---
*Initially written Sep 17, 2026 · Reviewed: Oct 15, 2026 · Edited: Oct 15, 2026 · Last review: Oct 15, 2026*

Topic: 技术与人造世界 › 计算技术与数字系统 › 计算机硬件 › Processors & processor engineering › Instruction set architectures › x86 ISA extensions

Copyright 2026 Edgepedia

License: Edgepedia Community License 1.0, https://www.edgepedia.org/edgepedia/license

Source: https://www.edgepedia.org/zh/sse4

English original: https://www.edgepedia.org/sse4
