[llvm] [SelectionDAG] Optimize 32-bit udiv with 33-bit magic constants on 64-bit targets (PR #181288)

MITSUNARI Shigeo via llvm-commits llvm-commits at lists.llvm.org
Thu Feb 12 23:32:02 PST 2026


herumi wrote:

>if you're only handling scalars isa<ConstantSDNode>(MagicFactor) is always true.

Thanks for the code review. I've removed it and use MagicFactor.

Algorithmically, it works even for large values.
However, this patch is optimized by taking advantage of the fact that on 64-bit CPUs there is little difference in instruction cost between 32x32->64 multiplies and 64x64->128 multiplies (on x86-64, Apple M series).
For larger sizes than that, the multiplication cost may become higher.


https://github.com/llvm/llvm-project/pull/181288


More information about the llvm-commits mailing list