Date: Sun, 28 Feb 2021 19:58:27 +0000 From: Jon Chesterfield <jonathanchesterfield@...il.com> To: musl@...ts.openwall.com, Mattias Andrée <maandree@....se> Subject: Re: [PATCH v2 2/2] Use modulo instead of mul+sub in __secs_to_tm On Sun, 28 Feb 2021, 19:37 Szabolcs Nagy, <nsz@...t70.net> wrote: > * Mattias Andrée <maandree@....se> [2021-02-28 20:22:10 +0100]: > > On x86 modulo is free when doing division, so this removes > > there should be no division. > > div by const is transformed to mul and shift at -O1 and > that's what we should be using instead of manual hacks. Right. Divide by constant is cheap because compilers have a bunch of transforms to get rid of the divide in favour of one of more cheaper instructions. Note that module coming for free with division doesn't make it cheap. Integer division is far more expensive that integer multiply on ~ every architecture. Several architectures implement division in software. It's not cheap on x86, despite the dedicated instruction. Cheers Content of type "text/html" skipped
Powered by blists - more mailing lists
Confused about mailing lists and their use? Read about mailing lists on Wikipedia and check out these guidelines on proper formatting of your messages.