Path: csiph.com!eternal-september.org!feeder.eternal-september.org!nntp.eternal-september.org!.POSTED!not-for-mail
From: Tim Rentsch
Newsgroups: comp.arch
Subject: Re: endian history
Date: Tue, 22 Sep 2026 16:55:50 -0700
Organization: A noiseless patient Spider
Lines: 39
Message-ID: <861paku9h5.fsf@linuxsc.com>
References: <10uks4f$1dqo$1@gal.iecc.com> <10vnjp6$1df4$1@gal.iecc.com> <10vns1f$3a252$1@dont-email.me> <10vpblp$3mkd1$1@dont-email.me> <10vphh0$3o9jl$1@dont-email.me> <117gj6t$1b95v$2@dont-email.me> <6a9c1c93.39172234@news.eternal-september.org> <117j3es$24qgq$6@dont-email.me> <117n6ho$35j69$1@paganini.bofh.team> <6a9f7664.1891062@news.eternal-september.org> <2026Sep8.125659@mips.complang.tuwien.ac.at> <117pnpg$f179$2@dont-email.me> <11898n9$1nc06$2@dont-email.me> <118d6ld$1tkm9$1@paganini.bofh.team> <118dl5f$37cfv$1@dont-email.me> <118e8kg$3f05h$1@dont-email.me> <868q4zuhz4.fsf@linuxsc.com> <118jitv$1cm6b$1@dont-email.me> <86ik42tcf4.fsf@linuxsc.com> <1790100995-5857@newsgrouper.org>
MIME-Version: 1.0
Content-Type: text/plain; charset=us-ascii
Injection-Date: Tue, 22 Sep 2026 23:55:51 +0000 (UTC)
Injection-Info: dont-email.me; logging-data="1377169"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX19zDK/mwpORIN87aI/nMIkGYy0QYDDtxbk="; posting-host="03472381143ebeb5b8a249e157345c91"
User-Agent: Gnus/5.11 (Gnus v5.11) Emacs/22.4 (gnu/linux)
Cancel-Lock: sha1:GAgMQpax03SwBBdBROLvDkBj+wY= sha1:U55AVDl2nXzsWAsg0sep+Lgu3ew= sha256:fYu1yCdxNuhhaHqHdlR4TKUmeSp+T+ulQF/9paURx58= sha1:ZZart4Ba8S+ecda9O8JvljwPnhQ= sha256:TJQxS41yRcwx8A/3Db1QjE5LVMmuo2OPGMYRScvsNgA=
Xref: csiph.com comp.arch:118137
MitchAlsup writes:
> Tim Rentsch posted:
>
>> Terje Mathisen writes:
>
> -----------------------
>
>>> In order to be really fast, the compiler has to recognize that both
>>> the div and mod should use reciprocal mul (standard), and if possible,
>>> only do it once.
>>> ...
>>> Checking Godbolt:
>>>
>>> Turns out it is actually generating two IMULs, but it should work for
>>> both positive and negative inputs...
>>
>> I suspect the two multiplys are a consequence of the usual way for
>> producing a quotient and remainder:
>>
>> quotient = n / BASE;
>> remainder = n - quotient*BASE
>
> What is wrong with the standard way::
>
> quotient = n / BASE; // 1 divide
> remainder = n % BASE; // no additional instruction
>
> ??
I didn't mean to suggest a way to write the code. I was trying to
explain how the compiler might have transformed the code, so as to
need two multiplies rather than one.
As it turns out, since I posted the earlier message, I have looked
into this matter a bit more, and this proposed explanation isn't
right. I think I now understand why there were two multiplies,
but I haven't investigated that further because of possible
differences between C and Rust.