From mboxrd@z Thu Jan 1 00:00:00 1970 X-Spam-Checker-Version: SpamAssassin 3.4.4 (2020-01-24) on inbox.vuxu.org X-Spam-Level: X-Spam-Status: No, score=-3.4 required=5.0 tests=DKIM_SIGNED,DKIM_VALID, DKIM_VALID_AU,FREEMAIL_FROM,HTML_MESSAGE,MAILING_LIST_MULTI, RCVD_IN_DNSWL_MED,RCVD_IN_MSPIKE_H3,RCVD_IN_MSPIKE_WL autolearn=ham autolearn_force=no version=3.4.4 Received: (qmail 19145 invoked from network); 28 Feb 2021 19:58:53 -0000 Received: from mother.openwall.net (195.42.179.200) by inbox.vuxu.org with ESMTPUTF8; 28 Feb 2021 19:58:53 -0000 Received: (qmail 20387 invoked by uid 550); 28 Feb 2021 19:58:51 -0000 Mailing-List: contact musl-help@lists.openwall.com; run by ezmlm Precedence: bulk List-Post: List-Help: List-Unsubscribe: List-Subscribe: List-ID: Reply-To: musl@lists.openwall.com Received: (qmail 20369 invoked from network); 28 Feb 2021 19:58:51 -0000 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=mime-version:references:in-reply-to:from:date:message-id:subject:to; bh=g9oVG3powAWBKc62Kamjdz1LmQ6mlmVEF9O9+RvLLJc=; b=t1dML39nw7xRCT51M4+YWei8ceELqBSdMt5lddOIv2UJHyxX3S70cKAPgyGOVGuFOO VFFLDeXQL+aaWm9SP14kNibrjn1syU4NSDPh2yhHFkBX/axdOoYG2zW4jPBBEchEKtpe ubDBUkBAneRQP2ucktXsh0vwROnSzFw7aahdBa6McXS2IIGNn3o8rknLdyWdLNKFgj2y beammVwR/F0H7BHLf/U9E+OGVpus6/x+aRC/YroSp1cAmYnWvmlBjjX6n2hNH5RnS7hT sYwf61VQVu4mk0PSdhxBGnRQK67NoHUxWlunTc6nT/vW9h+GMNldhEpykii1HPY6Auie cY6g== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to; bh=g9oVG3powAWBKc62Kamjdz1LmQ6mlmVEF9O9+RvLLJc=; b=FuN7oPq3Pi0Lc0dciAZLJ5wC/2QYdLYnnVVOQf/tE5I4guJWskMvg5MuXAxyiGzXcQ L7D5ZljK7JO/CI3j1Uyhfh+buO0/rOAhWYmshjT0rBCEsmqCzVx1hq8PaU8QhtXwK4JS Ee1PztxAnV8xP5MNVFZoE+bnpwX9FfGB5hSK7FCiQGptLtGIVMbFzm6G/gqQ59oPD7XA 2O/BI6m0hnbN6JN122gDEAf8XW651NPr8JDL/RIG05fOYDdtJFm2Ij/EORrn1LxRfb5w Bnoc1u8usEQ+QYJtjrUlmSO3caRBs7heDy+s/QZxqUEmiAcHKtz9ZEgrgCVX4yDgxi0Q vxAg== X-Gm-Message-State: AOAM532bpLcw9Lh78xDW9p4sNxXkHT0ioRf1Q+Y7f2pmhBwH18TjPGV1 l/Giyy1ea1rcX5xlJ+6CnSYZLgvX4U1W3FLO7u4QqRFT7B0= X-Google-Smtp-Source: ABdhPJwfMm6K941enXj/0wYUDxCOMHJk906S5ZFMAlVPLC5t2xXvUvHa0i2CDMoODohWRQHGDGLvc7kEzno8mWaWVtE= X-Received: by 2002:a9d:7d85:: with SMTP id j5mr10758728otn.152.1614542318946; Sun, 28 Feb 2021 11:58:38 -0800 (PST) MIME-Version: 1.0 References: <20210228150912.1532943-1-maandree@kth.se> <20210228192210.1665554-1-maandree@kth.se> <20210228192210.1665554-2-maandree@kth.se> <20210228193733.GF354034@port70.net> In-Reply-To: <20210228193733.GF354034@port70.net> From: Jon Chesterfield Date: Sun, 28 Feb 2021 19:58:27 +0000 Message-ID: To: musl@lists.openwall.com, =?UTF-8?Q?Mattias_Andr=C3=A9e?= Content-Type: multipart/alternative; boundary="000000000000654c7b05bc6aedcf" Subject: Re: [musl] [PATCH v2 2/2] Use modulo instead of mul+sub in __secs_to_tm --000000000000654c7b05bc6aedcf Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable On Sun, 28 Feb 2021, 19:37 Szabolcs Nagy, wrote: > * Mattias Andr=C3=A9e [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 --000000000000654c7b05bc6aedcf Content-Type: text/html; charset="UTF-8" Content-Transfer-Encoding: quoted-printable

On Sun, 28 Feb 2021, 19:37 Szabolcs Nagy, <nsz@port70.net> wrote:
* Mattias Andr=C3=A9e <maandree@kth.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 con= stant is cheap because compilers have a bunch of transforms to get rid of t= he divide in favour of one of more cheaper instructions.

Note that module coming for free with divi= sion 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 inst= ruction.

Cheers
--000000000000654c7b05bc6aedcf--