Follow @Openwall on Twitter for new release announcements and other news
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Date: Sun, 28 Feb 2021 19:58:27 +0000
From: Jon Chesterfield <>
To:, Mattias Andrée <>
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, <> wrote:

> * Mattias Andrée <> [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

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.


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.