From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-17.3 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER, INCLUDES_PATCH,MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,USER_AGENT_SANE_1 autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 43734C48BE0 for ; Wed, 9 Jun 2021 20:30:13 +0000 (UTC) Received: from phobos.denx.de (phobos.denx.de [85.214.62.61]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 05C3061278 for ; Wed, 9 Jun 2021 20:30:09 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 05C3061278 Authentication-Results: mail.kernel.org; dmarc=none (p=none dis=none) header.from=konsulko.com Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=u-boot-bounces@lists.denx.de Received: from h2850616.stratoserver.net (localhost [IPv6:::1]) by phobos.denx.de (Postfix) with ESMTP id 2658A82E99; Wed, 9 Jun 2021 22:30:07 +0200 (CEST) Authentication-Results: phobos.denx.de; dmarc=none (p=none dis=none) header.from=konsulko.com Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=u-boot-bounces@lists.denx.de Authentication-Results: phobos.denx.de; dkim=pass (1024-bit key; unprotected) header.d=konsulko.com header.i=@konsulko.com header.b="qFYXwBDQ"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id 7C18E82E99; Wed, 9 Jun 2021 22:30:05 +0200 (CEST) Received: from mail-qk1-x730.google.com (mail-qk1-x730.google.com [IPv6:2607:f8b0:4864:20::730]) (using TLSv1.3 with cipher TLS_AES_128_GCM_SHA256 (128/128 bits)) (No client certificate requested) by phobos.denx.de (Postfix) with ESMTPS id B6F9B82D15 for ; Wed, 9 Jun 2021 22:30:01 +0200 (CEST) Authentication-Results: phobos.denx.de; dmarc=none (p=none dis=none) header.from=konsulko.com Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=trini@konsulko.com Received: by mail-qk1-x730.google.com with SMTP id i67so25056322qkc.4 for ; Wed, 09 Jun 2021 13:30:01 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=konsulko.com; s=google; h=date:from:to:cc:subject:message-id:references:mime-version :content-disposition:in-reply-to:user-agent; bh=vTzVrBwhjxguE0NR7NiVGb1tLDmDlFVKIDrsew01FzI=; b=qFYXwBDQrl+CG4LpCSEvwIUcCSlg/bH3XHLXJgFN+8YvhAS/o4nBxI+myCUSGIXP7e Foadkj7nlpEKJ6T5SMdrBxHYcDsN0/PWzQvM3kSB1M9A/mfT14HGEEEparvirJhMInZu olO5JYOP2XsTQRdk5RI1RoJSTDfJXICXXfjfQ= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:date:from:to:cc:subject:message-id:references :mime-version:content-disposition:in-reply-to:user-agent; bh=vTzVrBwhjxguE0NR7NiVGb1tLDmDlFVKIDrsew01FzI=; b=EBwN1H3Pdgey1aqH2DqImCt6SYs6PID7nTElFqHzfIIKAoqj0+E3iw04WDivYysPaw i8wvJdN3ZdGYoIa4RsrLoPZeiKWpqIikFLRcM0Wb1VwKaw/ek9okKZ+n+CwRMe2pHEsw 3Tgu8gxF+0YTsm/m/Hs4LPYdlCF0D0RcNtJf6OwNoDNFeDUJg8g5xu4ay3A9M/Owb2TF fBqF+Yu05E10iI700C/BojhsOZsQ/1aLtIb44wmSp+PMQrzrId7D43JkWjVLwaUJcTXe BOo3j5H9FLd9s9NzlbApbOvj1U1c3zvUUyBKb3rYniNdSUXuc1EyIlrTGEs2lQ7oWmxi w53w== X-Gm-Message-State: AOAM532B890e/fv6n8HYdQv5oRHU1DLo0Ssp65vJnALsrIPrY2GlPYsd MW7WWPbMuyL+FZKN+JcvCBGHhyfuU9nAdQ== X-Google-Smtp-Source: ABdhPJzVTt6i516OrgIDq6xC/T98WXOZDGnG2ZpWutYmghrr7V3NK7waBVB0ZRFBLA/JSVDOgKsnPA== X-Received: by 2002:a05:620a:2945:: with SMTP id n5mr1459349qkp.224.1623270599245; Wed, 09 Jun 2021 13:29:59 -0700 (PDT) Received: from bill-the-cat (2603-6081-7b01-cbda-b9ef-ba99-589b-078c.res6.spectrum.com. [2603:6081:7b01:cbda:b9ef:ba99:589b:78c]) by smtp.gmail.com with ESMTPSA id j14sm730088qtj.96.2021.06.09.13.29.58 (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Wed, 09 Jun 2021 13:29:58 -0700 (PDT) Date: Wed, 9 Jun 2021 16:29:56 -0400 From: Tom Rini To: Christian Melki Cc: u-boot@lists.denx.de Subject: Re: [PATCH] Add udivmoddi4. Message-ID: <20210609202956.GM9516@bill-the-cat> References: <20210607092047.13246-1-christian.melki@t2data.com> <20210609183103.GK9516@bill-the-cat> MIME-Version: 1.0 Content-Type: multipart/signed; micalg=pgp-sha512; protocol="application/pgp-signature"; boundary="GOYy6nE9rVgTbVLg" Content-Disposition: inline In-Reply-To: X-Clacks-Overhead: GNU Terry Pratchett User-Agent: Mutt/1.9.4 (2018-02-28) X-BeenThere: u-boot@lists.denx.de X-Mailman-Version: 2.1.34 Precedence: list List-Id: U-Boot discussion List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: u-boot-bounces@lists.denx.de Sender: "U-Boot" X-Virus-Scanned: clamav-milter 0.102.4 at phobos.denx.de X-Virus-Status: Clean --GOYy6nE9rVgTbVLg Content-Type: text/plain; charset=us-ascii Content-Disposition: inline Content-Transfer-Encoding: quoted-printable On Wed, Jun 09, 2021 at 09:20:20PM +0200, Christian Melki wrote: > On 6/9/21 8:31 PM, Tom Rini wrote: > > On Mon, Jun 07, 2021 at 11:20:47AM +0200, Christian Melki wrote: > >=20 > >> A newer toolchain will emit udivmoddi4 for certain divide + modulo > >> operations instead of a separate divide and modulo operation. > >> AFAIU, this would be sufficient. > >> > >> Signed-off-by: Christian Melki > >> --- > >> arch/x86/lib/div64.c | 5 +++++ > >> 1 file changed, 5 insertions(+) > >> > >> diff --git a/arch/x86/lib/div64.c b/arch/x86/lib/div64.c > >> index 2bea205f60..a5b536fbc5 100644 > >> --- a/arch/x86/lib/div64.c > >> +++ b/arch/x86/lib/div64.c > >> @@ -110,3 +110,8 @@ u64 __umoddi3(u64 num, u64 den) > >> _64bit_divide(num, den, &v); > >> return v; > >> } > >> + > >> +u64 __udivmoddi4(u64 num, u64 den, u64 *rem) > >> +{ > >> + return _64bit_divide(num, den, rem); > >> +} > >=20 > > How do you trigger this and should you not be using do_div(), etc, > > instead? > >=20 >=20 > I probably should. Was trying to minimize various dependencies on u-boot > code (atleast with function separation) while trying to implement a > redundancy boot mechanism as a cmd. Triggered by using two consecutive > calls between the same variables for division and remainder as pure > operands with a gcc 9.3 x86 toolchain. >=20 > U-boot has no div_up afaik? >=20 > a =3D b / c; > if (b % c) { > a++; > } >=20 > b / c and b % c gets optimized / translated to udivmoddi4 as one operatio= n. I think you should look at include/div64.h and see if what you want is handled by something there already. --=20 Tom --GOYy6nE9rVgTbVLg Content-Type: application/pgp-signature; name="signature.asc" -----BEGIN PGP SIGNATURE----- iQGzBAABCgAdFiEEGjx/cOCPqxcHgJu/FHw5/5Y0tywFAmDBJMEACgkQFHw5/5Y0 tyz3UAv/deQxIU4KVixBC+kxd3moWMiqXEsdHgO9D07EIGgl1vI8QmAuFjrR+/Z2 TpO6UbCB1uki+u1FYf+mq2YLsOh19cU5SUzI8BTqf1d0nwgWGFsAoRRgbRasAP3j IgeN4WiAqTpVsn1NJM7X/W08itfccKmRhlD+xekN+xdgqqnWELtD3FYCDi4PTfnn eTv7oxBEtz4FeU9Vo/NZyPR08miHTzlMjeNIg00PEiOeWXs3f5Gl0WWqWBEmVGqg MNKkA0+Ym0SQAM10i415FMzgtKoHUHwD+uZuOxCYkjAlOEVV1AbgYrFvkQGibx8q PYHV5fDWAnsHstygb+yMTCDZWPwviVy9h/8x5jggEeCOhfFwqjyEHxDwcKzM7np1 OTTFG5vwIGUF5MFKQ9D7lpTz5sh0/+V10qj/ch5y/19wTKGEc7ntluQFh5+Xdv+t eUzDotLQ6sUQzsTm3lK86cdn4/b4cdPZ8+f/oDr1f0LKEwft5U8N6Fz7uxutqgJc 3r+GIjSz =G2cY -----END PGP SIGNATURE----- --GOYy6nE9rVgTbVLg--