Article View: comp.arch
Article #465Re: Register windows (was: Why VAX Was the Ultimate CISC and Not RISC)
From: MitchAlsup
Date: Fri, 30 Oct 2026 18:34
Date: Fri, 30 Oct 2026 18:34
180 lines
9916 bytes
9916 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:
> >> 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.
2-fetches per cycle giving almost 3 lines of instructions for decode.
> So there might be about 8 cache lines fetched between the prediction
> of the line that includes the return instructions and the actual fetch
> of the return instruction. The predictor has to predict the target of
> the return as the next prediction.
>
> Now if you want to wait for the result of the return-address load, you
> have to contend not just with the latency of the I-cache fetch of this
> load, but also the decoding, renaming, scheduling, and execution
> (D-cache latency) of this load, typically 10-20 cycles total.
That is the latency of verification of the prediction.
> So you
> would have to fetch this load 10-20 cycles (and thus 10-20 cycles
> worth of instructions, i.e. 100-200 instructions on a 10-wide machine)
> to have its result ready for using it to fetch the cache line after
> the return instruction (but of course that does not consider that in
> such a predictorless design, the return instruction also takes its
> time to decode etc.).
>
> Anyway, thanks to branch prediction and speculative execution, that's
> not necessary.
>
> >When RET is 16-odd instructions (all LDDs) from the current INSERT
> >point, you aren't at the point you can make a prediction (by couple
> >of cycles).
> >
> >The thing is that there may be 16 register loads between the point where
> >the compiler knows a return is going to happen and the RET instruction
> >itself (in whatever guise). Given that each takes an instruction, then
> >we get to the point where moving those 16 register loads through DECODE
> >prevents FETCH/PREDICT from seeing the RET for several cycles.
>
> Concerning the 16 loads, I don't think I have ever seen a compiler
> generate that many in front of a return. It would require that the
> calling convention has at least 16 callee-saved registers, and that
> they are all being used.
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.)
> But anyway, even assuming there is this bunch of loads, and the
> pipeline from the renamer to the scheduler(s) of the load/store units
> is narrow and there is no buffering capacity in between, there is no
> reason why the predictor would not predict the return. 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. We always verified that there
was a flow-control instruction as a qualification to the predictor.
> Of course, with a design that suffers from congestion between the
> renamer and the schedulers, the congestion will eventually clog the
> front end back to the instruction fetcher, and then even having a
> preduction early will not help. If this is a common occurence, the
> microarchitecture is obviously badly balanced for the workloads it
> uses.
Key point: DECODE needs a mechanism that "smoothly" deals with FU
overcommitment.
> BTW, what is the INSERT point?
It is where the instruction is far enough into the pipe that natural
FU scheduling runs it to completion {This is mostly when the Inst is
written into Reservation Station.}
> >But the
> >EXIT instruction itself makes DECODE know that a bunch of register LDs
> >will happen and a RET will also happen, so it arranged that RA is fetched
> >first and then used to fetch instructions at RA and feed DECODE while all
> >the LDs are transpiring.
>
> Ok, so you are assuming that the congestion has not clogged the
> decoder. In that case, a design with a predictor will happily fetch
> the target of the return and feed it into the decoders.
ENTER and EXIT invent the STs and LDs needed in a way easy for DECODE to
digest. EXIT in particular {with inst<3>==0} will return; and even if
there are a lot of LDs to be performed <via EXIT>, RA can be sent to
FETCH far earlier, ...
> >Yes, it is easy to predict RET and to fetch instructions there. So, let's
> >say we predict the RET and we also "predict" <in some manner> the sub-
> >sequent call. So, while we are still LDing registers, we now need to ST
> >a bunch of registers {new epilogue} onto the same memory currently being
> >LDed.
>
> I assume you mean "{new prologue}". -- YES YES
>
> And you assume that the next call also makes use of many callee-saved
> registers.
Sure, setting up the scenario.
> >The predictive mechanics to determine that the new epilogue is storing
> >bit patterns that are already in those memory locations is "non trivial"
> >for RISC-V but trivial for EXIT-CALL-ENTER.
>
> Are the same registers saved to the same places? If that is a common
> occurence (I don't think so), recognizing and optimizing it in
> hardware (probably in the renamer) looks doable.
My 66000 ABI (and SBI) both operate that way. ENTER saves registers
where higher register numbers are stored at higher memory locations.
> >{For most leaf functions;
> >there is only RET with no preserved register restoration and no EXIT}.
>
> If you need so many registers that you also use callee-saved
> registers, the callee also saves them when the callee is a leaf
> function.
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
> Of course, for values that do not live across a call
> (i.e. all values in a leaf function), caller-saved registers are the
> first pick.
>
> >So, the question, here, boils down to: "How many cycles does it take
> >DECODE to 'process' 16-LDDs in a row". Even a 10-wide machine may only
> >have 4 LD/MEM FUs, so it would take 4-odd cycles to push LDDs through
> >DECODE
>
> I would not know why a 10-wide decoder would not decode 10 loads per
> cycle. Likewise for the renamer. Then the schedulers may be more
> limited, but if so, and having loads and stores in large bunches is
> common, a competent designer will insert some buffering capacity to
> avoid congesting the front end.
>
> >and at cycle 2 one could be able to predict RET--whereas My
> >66000 can predict {with 100% confidence} 2-cycles earlier.
>
> You mean, it can resolve the prediction two cycles earlier. Given
> that return stack prediction is very accurate, the benefit might be
> that one can use a smaller ROB, if the prediction of return was the
> only reason for having a large ROB. But I think that other reasons
> for having a large ROB (such as conditional branches, or cache misses)
> stull persist and are actually more important.
>
> - anton
Technical Details
Message-ID:
<1793385253-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>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> Date: Fri, 30 Oct 2026 18:34:13 GMT Mime-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Message-ID: <1793385253-5857@newsgrouper.org> Injection-Info: newsgrouper.org; mail-complaints-to="newsgrouper@yahoo.com"; posting-account=user5857 Injection-Date: Fri, 30 Oct 2026 18:34:13 GMT User-Agent: Newsgrouper/0.9.0