GCC Newspaper
JULY 29, 2026
Date
/
Architectures
Components
Topics
News & Policy
i386 Performance Win

Add BMI2 MULX instruction pattern for efficient highpart multiplication.

New MULX instruction pattern optimizes high part of unsigned multiplication on BMI2 targets.

GCC now utilizes the BMI2 MULX instruction to directly compute the high part of an unsigned multiplication, replacing a less efficient sequence involving MULQ and a subsequent move to RDX. This optimization reduces instruction count for operations like 32-bit unsigned division by constants requiring 33-bit magic multipliers, changing the sequence from 4 to 3 instructions on BMI2-capable processors.

In Details

A new instruction pattern, *bmi2_umul<mode>3_highpart, is added to i386.md. This pattern leverages the MULX instruction available on Intel's BMI2 instruction set extension to directly produce the high-order bits of a 64-bit multiplication result into a destination register, avoiding the need for a separate instruction to extract the RDX register's content which occurs with the older MULQ instruction.

For Context
BMI2
A set of advanced bit manipulation instructions introduced by Intel, including instructions for efficient multiplication and bit shifting.
MULX
An instruction in the BMI2 set that performs a multiplication and writes the high-order 64 bits of the result to a destination register, while the low-order 64 bits go to the RDX register.
highpart
Refers to the most significant bits of a multiplication result. For a 64x64 multiplication, the result is 128 bits; the highpart is the upper 64 bits.
Filed Under: i386optimizationbmi2