Andreas Schwab wrote in <871qo6f90g....@igel.home>: |On Jan 07 2023, Greg Wooledge wrote: |> The variable l is a modulus, so its largest possible value is 127772. |> If the code simply said "l = ret % 127773;" then it wouldn't even be |> an issue. But the % was rewritten, presumably for efficiency. | |Presumably the assumption was that two divides are more costly than a |divide and a multiply (although nowadays, compilers will try to combine |the two divides if the target architecture has a divmod insn).
Seems to me that even twenty years ago gcc turned many divisions into multiplications if it could. (Which always stunned me as a non-mathematician.) --steffen | |Der Kragenbaer, The moon bear, |der holt sich munter he cheerfully and one by one |einen nach dem anderen runter wa.ks himself off |(By Robert Gernhardt)