Article View: comp.arch
Article #479Re: Register windows (was: Why VAX Was the Ultimate CISC and Not RISC)
From: Anton Ertl
Date: Sat, 31 Oct 2026 08:13
Date: Sat, 31 Oct 2026 08:13
106 lines
6576 bytes
6576 bytes
MitchAlsup <user5857@newsgrouper.org.invalid> writes:
>anton@mips.complang.tuwien.ac.at (Anton Ertl) posted:
>
>> MitchAlsup <user5857@newsgrouper.org.invalid> writes:
>> >anton@mips.complang.tuwien.ac.at (Anton Ertl) posted:
>> >> In a modern
>> >> (post-1995, with a few exceptions, most of which have died out in the
>> >> meantime) processor the front end predicts the return from the
>> >> processor-internal return stack and often starts fetching from there
>> >> before the load-store unit sees the load of the return address. The
>> >> return address is then used to validate the branch prediction and
>> >> retire the return instruction.
>> >
>> >You can't predict until you are within <about> 2-fetch cycles of the
>> >instruction you are going to make a prediction about {RET here}.
>>
>> Predictors can make predictions about anything. But given that it is
>> only useful to make predictions that are actually used, they will only
>> predict the next few I-cache lines to be fetched, so yes, predicting a
>> few fetch lines ahead could be common.
>>
>> How many? Depends on the latency of the I-cache. Given that it is
>> typically similar in size to the D-cache, it's latency will also be
>> similar, i.e., around 4 cycles.
>>
>> How many cache lines are fetched per cycle? With a 10-wide front end,
>> you probably do not want to underutilize the rest of the front end if
>> there is a taken branch or there is a branch to a target less than 10
>> instructions from the end of the cache line, so better fetch two cache
>> lines per cycle.
>
>A cache line contains 16 instructions, so one would assume a partial
>line is held over (to the next decode cycle) and one makes 1 fetch
>in the sequential direction and 1 fetch to another predicted address.
With this design the rest of the front end would not be fully utilized
if there are is more than on taken branch per n instructions (where n
is the decode width). With 10-wide designs, that's restrictive. I
have programs here that have more than 1 taken branch on 10
instructions:
perf stat -e instructions:u -e br_inst_retired.near_taken:u ./magichex 3 2
...
143280237 instructions:u
16156505 br_inst_retired.near_taken:u
That's 8.9 instructions per taken branch.
perf stat -e instructions:u -e br_inst_retired.near_taken:u gforth-fast --no-dynamic onebench.fs
4249141031 instructions:u
661631554 br_inst_retired.near_taken:u
That's 6.4 instructions per taken branch.
Although, admittedly, in the last case if we take the "--no-dynamic"
away, this reduces the number of taken branches more than the number
of instructions, resulting in more than 10 instructions per taken
branch:
2026987196 instructions:u
175323098 br_inst_retired.near_taken:u
But it uses dynamic native-code generation, which you have poo-pooed
as "self-modifying code", so presumably My 66000 will have to fall
back to --no-dynamic and will have to take at least 661M cycles for
this benchmark if it can only deal with one taken branch per cycle,
whereas even a lowly Darkmont (Core Ultra 225 E-Core) can run this
benchmark on 440M cycles.
>I have numerous examples of RISC-V (LLVM -O3) having 13 STs in prologue
>and 13 LDs in epilogue. The distribution (excepting for leaf functions
>(0 saved) and director functions (1 saved) is basically a Bell Curve
>from 2->13.)
It's interesting that you have numerous examples of needing 13
callee-saved registers for non-leaf functions, but apparently the 16
caller-saved registers are enough for the leaf functions; i.e., there
is not a single leaf function that needs more than 16 registers (the
number of caller-saved registers in the RISC-V ABI).
>> It does not
>> need to decode the return instruction to predict it, it just needs to
>> predict that there will be a return, and then use the hardware return
>> stack to make the prediction.
>
>Maybe predictors have gotten that good.
They have to. You cannot afford to wait to decode a branch before
starting to predict it when you need to be able to deal with 1-2 taken
branches per cycle. If you wait for the fetch and the decode before
starting to predict, you will see at most 1 taken branch every n
cycles, where n=fetch_latency+decode_latency+predictor_latency, i.e.,
>5 cycles on a modern CPU, possibly more like 10 cycles. With one
taken branch every 10 instructions or so, this would limit your IPC to
1-2, and much of the 10-wide design would starve.
>No, of course not. Leaf functions (93%) save no registers at all as they
>perform their duties in the freely-available temporary registers R0..15
If a leaf function needs more GPRs, it use callee-saved registers, and
will save them in the prologue and load them in the epilogue.
- anton
--
'Anyone trying for "industrial quality" ISA should avoid undefined behavior.'
Mitch Alsup, <c17fcd89-f024-40e7-a594-88a85ac10d20o@googlegroups.com>
Technical Details
Message-ID:
<2026Oct31.091342@mips.complang.tuwien.ac.at>Path:
mbox-mo1.pugleaf.net!archive.usenet.blueworldhosting.com!usenet.blueworldhosting.com!diablo1.usenet.blueworldhosting.com!eternal-september.org!feeder.eternal-september.org!nntp.eternal-september.org!.POSTED!not-for-mailReferences:
<vpufbv$4qc5$1@dont-email.me> <1792870082-5857@newsgrouper.org> <11bj58a$327li$1@dont-email.me> <2026Oct26.193309@mips.complang.tuwien.ac.at> <11bob96$3af$2@gal.iecc.com> <11bpggu$1961c$1@dont-email.me> <1793120292-5857@newsgrouper.org> <2026Oct29.171118@mips.complang.tuwien.ac.at> <1793296454-5857@newsgrouper.org> <2026Oct29.190945@mips.complang.tuwien.ac.at> <1793305885-5857@newsgrouper.org> <2026Oct30.080654@mips.complang.tuwien.ac.at> <1793385253-5857@newsgrouper.org>Show Full Headers
Complete Article Headers
Path: mbox-mo1.pugleaf.net!archive.usenet.blueworldhosting.com!usenet.blueworldhosting.com!diablo1.usenet.blueworldhosting.com!eternal-september.org!feeder.eternal-september.org!nntp.eternal-september.org!.POSTED!not-for-mail From: anton@mips.complang.tuwien.ac.at (Anton Ertl) Newsgroups: comp.arch Subject: Re: Register windows (was: Why VAX Was the Ultimate CISC and Not RISC) Date: Sat, 31 Oct 2026 08:13:42 GMT Organization: Institut fuer Computersprachen, Technische Universitaet Wien Lines: 106 Message-ID: <2026Oct31.091342@mips.complang.tuwien.ac.at> References: <vpufbv$4qc5$1@dont-email.me> <1792870082-5857@newsgrouper.org> <11bj58a$327li$1@dont-email.me> <2026Oct26.193309@mips.complang.tuwien.ac.at> <11bob96$3af$2@gal.iecc.com> <11bpggu$1961c$1@dont-email.me> <1793120292-5857@newsgrouper.org> <2026Oct29.171118@mips.complang.tuwien.ac.at> <1793296454-5857@newsgrouper.org> <2026Oct29.190945@mips.complang.tuwien.ac.at> <1793305885-5857@newsgrouper.org> <2026Oct30.080654@mips.complang.tuwien.ac.at> <1793385253-5857@newsgrouper.org> Injection-Date: Sat, 31 Oct 2026 09:09:25 +0000 (UTC) Injection-Info: dont-email.me; logging-data="1033871"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX199uUux8wETM+XLBE+vwxWE"; posting-host="3ac4bdbf86557ee00395b878a304d3f2" Cancel-Lock: sha1:9d+Y/4HjJewo1LEnB/NugHiGNc4= sha256:3mBIi8r796S6mvzPUNLsJQxsbg/8y+XRAhv5vIOl2o0= sha1:Jzi+Aw4+6ttC7zUzugNZVDTRcbo= sha256:JMcw5rsnGAx1ePLz+4OC8VLFTej4AoR70zGVmUYJRXA= X-newsreader: xrn 10.11