Article View: comp.arch
Article #490Re: Register windows (was: Why VAX Was the Ultimate CISC and Not RISC)
From: MitchAlsup
Date: Sat, 31 Oct 2026 18:22
Date: Sat, 31 Oct 2026 18:22
141 lines
7686 bytes
7686 bytes
anton@mips.complang.tuwien.ac.at (Anton Ertl) posted:
> 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.
Remember, I am only shooting at a 6-wide machine. and for 6-wide, 1-
prediction per cycle is not very restrictive. Also note: I have
conditional PREDicates which take 20% of front-end-redirects away.
K9 was 8-wide and we did have 2-predictions per cycle to deal with.
> 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.
My statistics are low 9.x inst 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",
I have indeed.
> 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.
If --no-dynamic has to do with dynamically loaded libraries, ABI
allows for them via GOT (without PLT saving a branch in the process).
> >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).
There are leaf functions which need more than 16 registers--where did I
imply otherwise--there are "just not many".
> >> 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.
Which is why we built the packet cache for Mc 88120 and a trace cache
for K9. Mc 88120 could take all conditional branches per cycle and 1
conditional branch per cycle. K9 could take all unconditional and 2
conditional 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.,
I see fetch-latency running concurrently with predictor-latency.
I do not see DECODE-latency getting in the way.
> >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.
Fetching as described above, and with annotation as above; I don't
see a problem feeding DECODE with 6-instructions per cycle. Remember
that 10-wide machine is only retiring 3 I/c.
> >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.
Captain Obvious strikes again.
> - anton
Technical Details
Message-ID:
<1793470952-5857@newsgrouper.org>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!newsgrouper.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> <2026Oct31.091342@mips.complang.tuwien.ac.at>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!newsgrouper.org!.POSTED!not-for-mail From: MitchAlsup <user5857@newsgrouper.org.invalid> Newsgroups: comp.arch Subject: Re: Register windows (was: Why VAX Was the Ultimate CISC and Not RISC) 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> <2026Oct31.091342@mips.complang.tuwien.ac.at> Date: Sat, 31 Oct 2026 18:22:32 GMT Mime-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Message-ID: <1793470952-5857@newsgrouper.org> Injection-Info: newsgrouper.org; mail-complaints-to="newsgrouper@yahoo.com"; posting-account=user5857 Injection-Date: Sat, 31 Oct 2026 18:22:32 GMT User-Agent: Newsgrouper/0.9.0