Article View: comp.arch
Article #785Re: Large constants in RISC
From: Waldek Hebisch
Date: Tue, 17 Nov 2026 05:07
Date: Tue, 17 Nov 2026 05:07
151 lines
8640 bytes
8640 bytes
Anton Ertl <anton@mips.complang.tuwien.ac.at> wrote:
> quadibloc@invalid.com (John Savard) writes:
>>On Sat, 14 Nov 2026 19:10:17 GMT, anton@mips.complang.tuwien.ac.at
>>(Anton Ertl) wrote:
>>>antispam@fricas.org (Waldek Hebisch) writes:
>>>>I read what he wrote and I do not doubt that code having constants
>>>>in instructions is faster.
>>>
>>>AMD64 has large constants (or at least better support for large
>>>constants than ARM A64), yet according to reviews ARM A64
>>>implementations form Apple and IIRC also Qualcomm offer better
>>>performance than the best AMD64 implementations.
> ...
>>However, support for large constants, while it contributes to better
>>performance, is just one factor out of many. AMD64 has a baroque
>>instruction set, so in an ARM A64 chip, a larger proportion of the
>>transistors are doing useful work.
>
> And included in the "baroque" instruction set are instructions with
> 32-bit immediate operands, and a mov instruction with a 64-bit
> immediate operand.
>
> In any case, there is no empirical evidence "that having [large]
> constants in instructions is faster." And the weak evidence that we
> currently have, points in the other direction. So we have every
> reason to doubt that claim.
>
>>When power and heat are the
>>limiting factors, that should matter.
>
> Power and heat have been limiting factors since about 2005, if not
> earlier. In 2006, Apple switched from PowerPC (a RISC) to Intel's
> "baroque" IA-32 and later AMD64 offerings.
>
>>"AMD64 has a huge market for powerful desktop computers and servers,
>>while the only big market for ARM A64 is smartphones, and yet
>>according to reviews..."
>>
>>...because, at least up until very recently, Intel has had so much
>>money to spend that it could afford to engineer its chips so cleverly
>>as to make up for the CISC versus RISC disadvantage.
>
> In the late 1990s, AMD was a much smaller company than Intel, and also
> smaller than the larger members of the AIM (Apple, IBM, Motorola)
> consortium, and the "baroqueness" of IA-32 played a bigger role in the
> CPUs of the day, yet AMD managed to beat Intel in the GHz race and was
> very competetive in the following years, while the offerings of the
> AIM consortium were slow and only kept afloat by the faith in the
> church of Apple. And eventually Apple switched to Intel.
>
> It's not clear why the ARM A64 microarchtitects manage to outcompete
> AMD64 these days, while the AIM microarchitects could not do that in
> the early 2000s. Maybe there is something in the instruction sets
> that plays a role when you do 10-wide microarchitecture that was not
> an issue for 3-wide microarchitectures in the early 2000s.
I think that economic factors worked differently than you suggest.
AMD and Intel were hardware companies serving large software
market Power/PPC software market was much smaller and fragmented.
Given size of PPC software market really large investments in
hardware were hard to justify. Now "phone" market seem to be
larger than PC market and Apple has a lot of money, so serious
investment in chips make sense.
I also wonder how many microachitectures are there. My possibly
worong understanding was that at turn of century Intel had two
microarchitectural efforts, that is Pentum 4 intended as new
thing and continuation of Pentium 2/3 and that AMD concentrated
on just one microarchitecure. Intel got Pentum 4 wrong while
AMD succeded. Later with Core/Core 2 Intel got it right
while AMD had trouble. My impression was that various models
were relatively small variation of the same microarchitecure.
I compared performance of several low-end PC class processors
and I see wild variation of performance, which suggest that
now there are several microarchitecures. Still, it is likely
that there is very small number of microarchitecures for top
performing models. Possibly 1 microarchitecure in normal
time and 2 when there is transition between microarchitecures.
If that is true one can expect essentially random fluctuations
of comparative performance, depending on which team gets more
aspects right.
So beside underlying architecture there are two factors that
can explain good performance of ARM64: one in large influx of
money, the other is luck.
> Maybe Intel's APX (32 GPRs, 3-address encoding) is a reaction to Apple
> M1 having better IPC, and maybe we will see better IPC on Intel
> machines with APX. I would not bet on it, though.
When looking at technical factors I think that one aspect is
how much work is done by a single microinstruction. The other
is how much resources go into single microinstruction. That
is microinstruction which reads many registers and writes
many registers may do a lot of work, but needs more execution
resources. So, determining right complexity of
microinstructions needs tricky compromise. This compromise
is affected by architecture. For example, decoders may
fuse load and index increment into autoindexing, but in
case of architectural preincrement exception is just at
start of the instruction, while in fused case exception in
in the middle of synthetised instruction. I am not sure
how much this specific case matters, but it illustrates
that even with fusion and splitting architectural instruction
set forces differences at microarchitectural level. ARM64
is relatively new instruction set, so ARM should have
looked at interactions between architecture and
microarchitecture and optimize them.
I have impression that ARM64 code is bigger, so probably
also needs more instructions. But I would expect more
possibilites for fusing and since instructions have fixed
length and more regular encoding fusing should be easier
to implement than for AMD64. So number of microinstructions
to execute may be smaller. IIUC AMD64 for fast decoding
depends on predecode bits in cache. Assuming single
predecode bit per byte, AMD64 probably needs more cache
bits than ARM64.
Concerning specific features, ARM64 sets flags only on
demand, which reduces dependencies between instructions.
Autoincrement/autodecrement allow doing more work in
single instruction than AMD64.
More registers help, old statistics suggest that only
a little, but modern compilers perform a lot of
inlining, which increases instruction use. Also,
more architectural registers help in increasing
parallelizm at source level.
Concerning constants, by using ADRP in many cases it is
possible to get effect of 32-bit PC-relative address using
2 instructions. ARM64 can load 32 bit constant into
register using 2 instructions and can load 64 bit constant
into register using 4 intruction sequence. 2 instructions
are easily fusable, fusing 4 intructions needs more effort
but it is not clear if it is harder than decoding AMD64
instructions. So from my point of view main drawback
is need to use extra register, but since ARM64 has
significantly more registers this can not tip the balace
in favour of AMD64.
Let me add that I do not expect large performace improvement
from my proposal. Rather, I think that it is cheap to
implement and small variation of what some RISC-s already
do. I do expect some performance gain, and I hope that cost
to benefit ratio is reasonable, but I think that other
factors have more influence on performance.
For me main advantage is simplification of software.
--
Waldek Hebisch
Technical Details
Message-ID:
<11dgnf5$26qqi$1@paganini.bofh.team>Path:
mbox-mo1.pugleaf.net!news-lax.pugleaf.net!srl.newsdeef.eu!newsfeed.bofh.team!paganini.bofh.team!not-for-mailReferences:
<11d76uq$11cdc$1@paganini.bofh.team> <11d7ct8$17akn$1@dont-email.me> <11d7ih2$11orr$1@paganini.bofh.team> <11d9d0d$1rsce$1@dont-email.me> <11d9tq8$1b9c1$2@paganini.bofh.team> <2026Nov14.201017@mips.complang.tuwien.ac.at> <6af911ea.18530156@news.eternal-september.org> <2026Nov15.173606@mips.complang.tuwien.ac.at>Show Full Headers
Complete Article Headers
Path: mbox-mo1.pugleaf.net!news-lax.pugleaf.net!srl.newsdeef.eu!newsfeed.bofh.team!paganini.bofh.team!not-for-mail
From: antispam@fricas.org (Waldek Hebisch)
Newsgroups: comp.arch
Subject: Re: Large constants in RISC
Date: Tue, 17 Nov 2026 05:07:52 -0000 (UTC)
Organization: bofh.team Usenet service
Message-ID: <11dgnf5$26qqi$1@paganini.bofh.team>
References: <11d76uq$11cdc$1@paganini.bofh.team> <11d7ct8$17akn$1@dont-email.me> <11d7ih2$11orr$1@paganini.bofh.team> <11d9d0d$1rsce$1@dont-email.me> <11d9tq8$1b9c1$2@paganini.bofh.team> <2026Nov14.201017@mips.complang.tuwien.ac.at> <6af911ea.18530156@news.eternal-september.org> <2026Nov15.173606@mips.complang.tuwien.ac.at>
Injection-Date: Tue, 17 Nov 2026 05:07:52 -0000 (UTC)
Injection-Info: paganini.bofh.team; logging-data="2321234"; mail-complaints-to="usenet@bofh.team"; posting-host="d028f9ad2fa2c51f22dbfed0d81d7daf"; posting-account="69e66f1681224ab92235b464ce7a90b6"
User-Agent: tin/2.6.2-20221225 ("Pittyvaich") (Linux/6.1.0-9-amd64 (x86_64))
X-Postfilter: Postfilter-NG 2026.10.2