llvm-project
796b218e - [LegalizeTypes] Expand UDIV/UREM by constant via chunk summation (#146238)

Commit
32 days ago
[LegalizeTypes] Expand UDIV/UREM by constant via chunk summation (#146238) This patch improves the lowering of 128-bit unsigned division and remainder by constants (UDIV/UREM) by avoiding a fallback to libcall (__udivti3/uremti3) for specific divisors. When a divisor D satisfies the condition (1 << ChunkWidth) % D == 1, the 128-bit value is split into fixed-width chunks (e.g., 30-bit) and summed before applying a smaller UDIV/UREM. This transformation is based on the "remainder by summing digits" trick described in Hacker’s Delight. This fixes #137514 for some constants.
Author
Parents
Loading