Optimization of 32-bit Unsigned Division by Constants on 64-bit Targets

Fuente: arXiv
Gespeichert in:
Bibliographische Detailangaben
Hauptverfasser: Mitsunari, Shigeo, Hoshino, Takashi
Format: Preprint
Veröffentlicht: 2026
Schlagworte:
Online-Zugang:
Tags: Tag hinzufügen
Keine Tags, Fügen Sie den ersten Tag hinzu!
_version_ 1866908949271281664
author Mitsunari, Shigeo
Hoshino, Takashi
author_facet Mitsunari, Shigeo
Hoshino, Takashi
contents 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.
format Preprint
id arxiv_https___arxiv_org_abs_2604_07902
institution arXiv
publishDate 2026
record_format arxiv
spellingShingle Optimization of 32-bit Unsigned Division by Constants on 64-bit Targets
Mitsunari, Shigeo
Hoshino, Takashi
Programming Languages
Hardware Architecture
D.3.4
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.
title Optimization of 32-bit Unsigned Division by Constants on 64-bit Targets
topic Programming Languages
Hardware Architecture
D.3.4
url https://arxiv.org/abs/2604.07902