# AltiVec

**AltiVec** 是 PowerPC 架构上的单指令多数据（SIMD）向量扩展，增加了 32 个 128 位向量寄存器和一套用于执行向量与矩阵数学函数的指令集。Motorola 将 AltiVec 这一名称注册了商标；Apple 将同一单元营销为 **Velocity 引擎**，IBM 文档则称之为向量多媒体扩展（VMX）或简称 SIMD 向量扩展。<sup>[1](https://www.redbooks.ibm.com/redbooks/pdfs/sg247414.pdf)</sup><sup> • </sup><sup>[2](https://www.ibm.com/docs/en/aix/7.1.0?topic=concepts-aix-vector-programming)</sup>

| 关键事实 | 详情 |
|---|---|
| 起源 | 该指令集由 Keith Diefendorff（时任 Apple Computer 杰出科学家兼微处理器架构总监）于 1996 年至 1998 年间开发<sup>[1](https://www.redbooks.ibm.com/redbooks/pdfs/sg247414.pdf)</sup> |
| 寄存器文件 | 32 个额外的 128 位寄存器，可容纳有符号或无符号的 8 位、16 位或 32 位整数，或 32 位 IEEE 单精度浮点数，另有一个向量状态与控制寄存器（VSCR）<sup>[2](https://www.ibm.com/docs/en/aix/7.1.0?topic=concepts-aix-vector-programming)</sup> |
| 首次实现 | Motorola MPC7400（PowerPC G4），1999 年 8 月 31 日推出，350、400 和 450 MHz 版本千颗批发价分别为 210、275 和 355 美元<sup>[3](https://www.eetimes.com/apple-motorola-unveil-g4-powerpc/)</sup><sup> • </sup><sup>[4](https://www.eetimes.com/motorolas-new-mpc7400-microprocessor-delivers-performance-leap-for-embedded-and-desktop-systems/)</sup> |
| 浮点 | 仅支持单精度；就近舍入；IEEE-754 的 Java 子集，无异常标志，无硬件除法或平方根<sup>[5](https://preserve.mactech.com/articles/mactech/Vol.15/15.07/AltiVecRevealed/index.html)</sup><sup> • </sup><sup>[6](https://leopard-adc.pepas.com/documentation/Performance/Conceptual/Accelerate_sse_migration/migration_sse_translation/migration_sse_translation.html)</sup> |
| 编程接口 | 通过 `<altivec.h>` 提供 C 和 C++ 内建函数，GCC 中需使用 `-maltivec` 和 `-mabi=altivec` 编译选项<sup>[7](https://gcc.gnu.org/onlinedocs/gcc/PowerPC-AltiVec_002fVSX-Built-in-Functions.html)</sup> |
| 后续发展 | 作为 VMX 与 VSX 一同纳入 Power ISA（Power ISA 2.07 为 POWER8 制定）；大端 AltiVec 代码已从 FFmpeg 等项目中退役<sup>[8](https://www.redbooks.ibm.com/redbooks/pdfs/sg248280.pdf)</sup><sup> • </sup><sup>[9](https://ffmpeg.org/pipermail/ffmpeg-devel/2025-April/341937.html)</sup> |

## 架构

该向量扩展由一组额外的 32 个 128 位寄存器组成，可容纳有符号或无符号的 8 位、16 位或 32 位整数，或 32 位 IEEE 单精度浮点数。一个向量状态与控制寄存器保存一个粘滞状态位以指示饱和，以及一个控制位用于选择浮点运算的 Java 或非 Java 模式。<sup>[2](https://www.ibm.com/docs/en/aix/7.1.0?topic=concepts-aix-vector-programming)</sup> 由于一个 128 位寄存器可容纳十六个 8 位、八个 16 位或四个 32 位元素，每条指令可同时执行 16、8 或 4 次运算。<sup>[10](https://www.researchgate.net/publication/255630503_Exploiting_the_AltiVec_Unit_for_Commercial_Applications)</sup>

指令集按组划分，包括整数算术、浮点算术与估算、加载与存储、内存控制（缓存与数据流）指令，以及一大类排列与格式化指令：打包、解包、合并、广播、排列、选择和移位操作，用于在向量内部及向量之间重新排列数据。<sup>[11](https://www.nxp.com/docs/en/reference-manual/ALTIVECPEM.pdf)</sup> 排列指令是该架构对齐规则的标准补救手段：向量加载与存储以 16 字节为单位、按 16 字节边界对齐操作，未对齐的数据通过排列指令重新排序来处理。<sup>[10](https://www.researchgate.net/publication/255630503_Exploiting_the_AltiVec_Unit_for_Commercial_Applications)</sup>

**浮点设计。** 向量单元遵循性能驱动的简化模型。没有专用的向量乘法指令；程序员使用乘加指令并将加数寄存器初始化为 -0.0，从而为符合 IEEE 或 Java 的结果保留正确的零符号。没有除法或平方根指令，因为那将需要大量硬件并增加延迟；取而代之，AltiVec 提供向量倒数估算（`vrefp`）和倒数平方根估算（`vrsqrtefp`）指令，精度为 12 位，在需要更高精度时可馈入牛顿-拉夫逊法精化。<sup>[5](https://preserve.mactech.com/articles/mactech/Vol.15/15.07/AltiVecRevealed/index.html)</sup> 所有 AltiVec 浮点算术指令均使用 IEEE 默认的就近舍入模式，且通常不设置任何状态位来反映浮点结果。<sup>[11](https://www.nxp.com/docs/en/reference-manual/ALTIVECPEM.pdf)</sup>

VSCR[NJ] 位在两种浮点模式之间选择。Java 模式为默认模式，遵循 Java/IEEE/C9X 标准的一个子集：非规格化数作为输入和结果均受支持，无效运算产生 NaN，且仅提供就近舍入。非 Java 模式是一种精度较低的模式，在某些实现上可能运行显著更快；在 PowerPC 970 上，Java 模式指令遇到非规格化操作数会引发异常，由代价高昂的操作系统仿真处理，因此 AIX 文档建议在其舍入可接受时启用非 Java 模式。<sup>[11](https://www.nxp.com/docs/en/reference-manual/ALTIVECPEM.pdf)</sup><sup> • </sup><sup>[1](https://www.redbooks.ibm.com/redbooks/pdfs/sg247414.pdf)</sup>

## 历史与实现

该指令集由 Keith Diefendorff 于 1996 年至 1998 年间在 Apple Computer 开发。Motorola 将 AltiVec 一词注册了商标，因此 Apple 使用 Velocity 引擎这一名称；IBM 则将同一扩展称为 SIMD 或 VMX。<sup>[1](https://www.redbooks.ibm.com/redbooks/pdfs/sg247414.pdf)</sup> 1998 年中期 IBM 退出 Somerset 联合设计机构后，设计工作转回 Motorola，IBM 最初选择不支持该扩展，使 Motorola 成为 Apple 的 G4 唯一供应商。<sup>[12](https://www.techmonitor.ai/analysis/apple_must_rely_on_motorola_for_chips_now_altivec_is_key/)</sup>

Apple 与 Motorola 于 1999 年 8 月 31 日推出集成了 AltiVec 的 PowerPC G4，称其为 PC 提供了高性能的 DSP 式能力。<sup>[3](https://www.eetimes.com/apple-motorola-unveil-g4-powerpc/)</sup> Motorola 的 MPC7400 发布公告声称，128 位向量引擎与现有的浮点和整数单元并行工作，每时钟周期可执行 20 次运算，且 C/C++ 语言扩展使开发者能实现相对于标量代码平均 1.5 至 6 倍的加速，某些算法提速远超 10 倍。<sup>[4](https://www.eetimes.com/motorolas-new-mpc7400-microprocessor-delivers-performance-leap-for-embedded-and-desktop-systems/)</sup> Apple 的营销大力倚重该单元：[Power Mac G4](https://www.edgepedia.org/zh/power-mac-g4) 系列在推广时宣称，在 Apple 的测试中 Velocity 引擎运行 [Adobe Photoshop](https://www.edgepedia.org/zh/adobe-photoshop) 比基于 800 MHz Pentium III 的 PC 快 50% 以上。<sup>[13](https://www.apple.com/newsroom/2000/02/16Apple-Ups-Performance-of-Power-Mac-G4-Line/)</sup>

IBM 后来采纳了该扩展。PowerPC 970 实现了它，AIX 5.3 技术级别 5300-03 是首个支持向量编程的 AIX 版本，PowerPC 970 则是首个实现该扩展的 AIX 支持处理器。<sup>[2](https://www.ibm.com/docs/en/aix/7.1.0?topic=concepts-aix-vector-programming)</sup> 970 的后继产品线将该能力延续下去：Power ISA 为 POWER8 代规定了 VMX 和 VSX，GCC 为这些处理器实现了 AltiVec API 规范。<sup>[8](https://www.redbooks.ibm.com/redbooks/pdfs/sg248280.pdf)</sup>

## 编程模型

编译器通过重载 `vec_` 函数的高级语言接口暴露该单元。GCC 通过包含 `<altivec.h>` 并使用 `-maltivec` 和 `-mabi=altivec` 编译来提供该接口；支持的向量类型包括 `vector unsigned/signed/bool char`、`short` 和 `int`、`vector pixel` 以及 `vector float`。<sup>[7](https://gcc.gnu.org/onlinedocs/gcc/PowerPC-AltiVec_002fVSX-Built-in-Functions.html)</sup> GCC 的实现与 Motorola 文档在若干细节上有所不同，例如向量常量和关键字替换的行为，且它现在遵循 Power 向量内建编程参考，在 PVIPR 提供可移植接口之处将旧接口视为已弃用。<sup>[7](https://gcc.gnu.org/onlinedocs/gcc/PowerPC-AltiVec_002fVSX-Built-in-Functions.html)</sup> IBM 的 XL C/C++ 通过 `-qaltivec` 及其自有扩展支持相同的编程模型。<sup>[14](https://www.ibm.com/docs/en/xl-c-and-cpp-aix/16.1.0?topic=functions-vector-built-in)</sup>

在 PowerPC 970FX 上，AltiVec 单元的指令分布于各功能单元，延迟如下：向量简单整数单元（2 周期）、用于乘法、求和和最大值的向量复杂整数单元（5 周期）、向量浮点单元（8 周期）、排列单元（2 周期）以及加载与存储（4 周期）；每周期仅发射两条指令，其中一条可发往排列单元。<sup>[10](https://www.researchgate.net/publication/255630503_Exploiting_the_AltiVec_Unit_for_Commercial_Applications)</sup>

## AltiVec 与 SSE 的比较

AltiVec 和 x86 SSE 共享相同的基本设计——偏好 16 字节对齐数据的 128 位 SIMD，Apple 的迁移指南称两者之间具有“相当不错”的指令对等性：AltiVec 指令集中最常用的约 60% 至 70% 大多与 SSE 对应指令一一映射，SSE 不足之处需 2-3 条指令变通，在特别困难的情况下则需要新算法。<sup>[6](https://leopard-adc.pepas.com/documentation/Performance/Conceptual/Accelerate_sse_migration/migration_sse_translation/migration_sse_translation.html)</sup>

浮点环境在合规性和各自提供的额外功能上有所不同。AltiVec 提供 IEEE-754 的 Java 子集，仅就近舍入，非规格化数异常但无标志，除法和平方根由软件实现；SSE 完全符合 IEEE-754，支持全部四种舍入模式、完整的异常和标志，以及硬件除法和平方根。AltiVec 独有比较边界指令以及 log2(x) 和 2^x 估算，而 SSE 独有直接在向量寄存器上操作标量操作数的能力。<sup>[6](https://leopard-adc.pepas.com/documentation/Performance/Conceptual/Accelerate_sse_migration/migration_sse_translation/migration_sse_translation.html)</sup> 分支也有所不同：AltiVec 的比较操作在条件寄存器中设置位，处理器可直接据此分支；而 SSE 的比较不设置类似位，结果必须用 movemask 指令提取。<sup>[6](https://leopard-adc.pepas.com/documentation/Performance/Conceptual/Accelerate_sse_migration/migration_sse_translation/migration_sse_translation.html)</sup>

与 ARM 的 NEON 相比，ARM 对比表记录 AltiVec 具有 32 个 128 位寄存器、基于寄存器的 3 和 4 操作数指令、仅支持单精度浮点，且无法在标量与向量寄存器之间移动数据——而 NEON 和 x86 MMX/SSE 均提供此能力。<sup>[15](https://support.arm.com/documentation/den0018/a/Introduction/Comparison-between-ARM-NEON-technology-and-other-implementations/Comparison-between-NEON-technology-and-other-SIMD-solutions?lang=en)</sup>

## 实际性能

IBM 一项关于在 PowerPC 970FX 上向量化商业应用的研究报告了相对于优化标量代码的加速比：字符串比较 2-3 倍，XML 分隔符查找 1.5-5 倍，UTF-8 转换 2-4 倍；向量化梳排序运行快 5.0 倍，直至数据溢出 L2 缓存，将快速排序分区与向量化梳排序结合则获得超过 2.0 倍的加速。<sup>[10](https://www.researchgate.net/publication/255630503_Exploiting_the_AltiVec_Unit_for_Commercial_Applications)</sup> 同一研究还记录了该单元对商业代码的局限：不支持 32 位整数乘法或任何除法，不支持双精度浮点，且要求同构数据布局，因为抽象为异构结构的数据必须先提取出来才能向量化。<sup>[10](https://www.researchgate.net/publication/255630503_Exploiting_the_AltiVec_Unit_for_Commercial_Applications)</sup>

## 遗产

该扩展作为 VMX 存续于 Power ISA 中，与后来的 VSX（向量标量扩展）配对，后者扩展了向量寄存器文件并从 POWER7 起增加了双精度支持。<sup>[8](https://www.redbooks.ibm.com/redbooks/pdfs/sg248280.pdf)</sup><sup> • </sup><sup>[14](https://www.ibm.com/docs/en/xl-c-and-cpp-aix/16.1.0?topic=functions-vector-built-in)</sup> 原始的大端编程模型已从主流使用中淡出：小端 PowerPC 直到 2013 年的 POWER8 才真正投入使用，而在 2024 年和 2025 年，FFmpeg 项目移除了其大端 AltiVec DSP 和后处理代码，指出可工作的大端 PowerPC 硬件已难以获得。<sup>[9](https://ffmpeg.org/pipermail/ffmpeg-devel/2025-April/341937.html)</sup>

## References

1. [AIX 5L Differences Guide Version 5.3 Addendum, IBM Redbooks](https://www.redbooks.ibm.com/redbooks/pdfs/sg247414.pdf)
2. [AIX vector programming, IBM Documentation](https://www.ibm.com/docs/en/aix/7.1.0?topic=concepts-aix-vector-programming)
3. [Apple, Motorola unveil G4 PowerPC, EE Times](https://www.eetimes.com/apple-motorola-unveil-g4-powerpc/)
4. [Motorola's New MPC7400 Microprocessor Delivers Performance Leap for Embedded and Desktop Systems, EE Times](https://www.eetimes.com/motorolas-new-mpc7400-microprocessor-delivers-performance-leap-for-embedded-and-desktop-systems/)
5. [AltiVec Revealed, MacTech Vol. 15 No. 7](https://preserve.mactech.com/articles/mactech/Vol.15/15.07/AltiVecRevealed/index.html)
6. [AltiVec/SSE Migration Guide: Translating AltiVec to SSE, Apple Developer Documentation](https://leopard-adc.pepas.com/documentation/Performance/Conceptual/Accelerate_sse_migration/migration_sse_translation/migration_sse_translation.html)
7. [PowerPC AltiVec/VSX Built-in Functions, Using the GNU Compiler Collection](https://gcc.gnu.org/onlinedocs/gcc/PowerPC-AltiVec_002fVSX-Built-in-Functions.html)
8. [Implementing an IBM High-Performance Computing Solution on IBM Power System S822LC, IBM Redbooks](https://www.redbooks.ibm.com/redbooks/pdfs/sg248280.pdf)
9. [libpostproc: remove big-endian AltiVec acceleration, FFmpeg-devel mailing list](https://ffmpeg.org/pipermail/ffmpeg-devel/2025-April/341937.html)
10. [Citron, D. et al., Exploiting the AltiVec Unit for Commercial Applications, IBM Haifa/Tokyo Research Laboratories](https://www.researchgate.net/publication/255630503_Exploiting_the_AltiVec_Unit_for_Commercial_Applications)
11. [AltiVec Technology Programming Environments Manual, Rev. 3, Freescale/NXP](https://www.nxp.com/docs/en/reference-manual/ALTIVECPEM.pdf)
12. [Apple Must Rely on Motorola for Chips Now AltiVec is Key, Tech Monitor](https://www.techmonitor.ai/analysis/apple_must_rely_on_motorola_for_chips_now_altivec_is_key/)
13. [Apple Ups Performance of Power Mac G4 Line, Apple Newsroom, February 16, 2000](https://www.apple.com/newsroom/2000/02/16Apple-Ups-Performance-of-Power-Mac-G4-Line/)
14. [Vector built-in functions, XL C/C++ AIX Documentation, IBM](https://www.ibm.com/docs/en/xl-c-and-cpp-aix/16.1.0?topic=functions-vector-built-in)
15. [NEON programmers' guide: Comparison between NEON technology and other SIMD solutions, ARM](https://support.arm.com/documentation/den0018/a/Introduction/Comparison-between-ARM-NEON-technology-and-other-implementations/Comparison-between-NEON-technology-and-other-SIMD-solutions?lang=en)

---
*Initially written Oct 15, 2026*

Topic: 技术与人造世界 › 计算技术与数字系统 › 计算机硬件 › Processors & processor engineering › Instruction set architectures › Vector and SIMD instruction sets (cross-family)

Copyright 2026 Edgepedia

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

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

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