mosa / MOSA-Project

Managed Operating System Alliance Project
https://www.mosa-project.org/
Other
409 stars 81 forks source link

Optimize Integer Division with Constant Values #1138

Closed tgiphil closed 1 year ago

tgiphil commented 1 year ago

Read Hacker's Delight book.

Use the following to determine the magic numbers.

https://github.com/hcs0/Hackers-Delight/blob/master/magicu.c.txt

https://github.com/hcs0/Hackers-Delight/blob/master/magic.c.txt

tgiphil commented 1 year ago

Additional reference:

https://github.com/jart/cosmopolitan/blob/master/libc/tinymath/magicu.c https://github.com/jart/cosmopolitan/blob/master/libc/tinymath/magicu.h