News for hackers. Stuff that matters.
Re:How do compilers optimize divisions? by xelxebar on Wednesday February 22, 2017 @02:53AM (#13703943)
Is there a reason compilers don't just use modular inverses and let overflow take care of things?

19 * 678,152,731 = 1 (mod 2^32)

19 * 9,708,812,670,373,448,219 = 1 (mod 2^64)

As long as we already know the size of an int Euclid's algorithm should be able to find these inverses if they exist.

Re:How do compilers optimize divisions? by SamReidHughes on Thursday February 23, 2017 @01:43AM (#13712117)
That only works when the value is known to be a multiple of whatever you're dividing by, and they do use that when it is the case, such as for pointer subtraction.
Re:How do compilers optimize divisions? by jwilk on Wednesday February 22, 2017 @10:47AM (#13706351)
I don't see how finding the modular inverse helps with division.

What algorithm do you have in mind?