针对64位目标的32位无符号除以常数的优化
Optimization of 32-bit Unsigned Division by Constants on 64-bit Targets
AI总结:
本文提出一种针对64位CPU的32位无符号除以常数的优化方法,通过改进GM方法提升性能,在Intel Xeon w9-3495X和Apple M4上分别获得1.67x和1.98x的加速效果。
摘要:
Granlund和Montgomery提出了一种无符号整数除以常数的优化方法[3]。该方法(本文称为GM方法)在部分工作中如[1]和[7]中得到改进,并被GCC、Clang、微软编译器和Apple Clang等主流编译器采用。然而,例如x/7的生成代码是为32位CPU设计的,因此未能充分利用64位能力。本文提出了一种针对64位CPU的32位无符号除以常数的优化方法。我们为LLVM/GCC实施了补丁,并在后续描述的微基准测试中,在Intel Xeon w9-3495X (Sapphire Rapids) 上获得了1.67x的加速,在Apple M4 (Apple M系列SoC) 上获得了1.98x的加速。LLVM补丁已合并到llvm:main [6],证明了所提出方法的实用性。
英文摘要:
Granlund and Montgomery proposed an optimization method for unsigned integer division by constants [3]. Their method (called the GM method in this paper) was further improved in part by works such as [1] and [7], and is now adopted by major compilers including GCC, Clang, Microsoft Compiler, and Apple Clang. However, for example, for x/7, the generated code is designed for 32-bit CPUs and therefore does not fully exploit 64-bit capabilities. This paper proposes an optimization method for 32-bit unsigned division by constants targeting 64-bit CPUs. We implemented patches for LLVM/GCC and achieved speedups of 1.67x on Intel Xeon w9-3495X (Sapphire Rapids) and 1.98x on Apple M4 (Apple M-series SoC) in the microbenchmark described later. The LLVM patch has already been merged into llvm:main [6], demonstrating the practical applicability of the proposed method.
机构、总结、中文摘要均由AI分析而来,可能存在错误,请以论文正文为准。