Tune magic division for size

This helps it avoid generating a branch instruction.
This commit is contained in:
Justine Tunney 2023-05-10 21:32:04 -07:00
parent 1f6f9e6701
commit 8d24a18c62
No known key found for this signature in database
GPG key ID: BE714B4575D6E328

View file

@ -17,7 +17,7 @@ struct magicu __magicu_get(uint32_t);
* @param d should be `__magicu_get(y)` if computing `x / y`
* @return result of unsigned integer division
*/
static inline uint32_t __magicu_div(uint32_t x, struct magicu d) {
static inline optimizesize uint32_t __magicu_div(uint32_t x, struct magicu d) {
return ((((uint64_t)x * d.M) >> 32) + ((d.s & 64) ? x : 0)) >> (d.s & 63);
}