🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: comp.arch
Article #579

Re: Register windows

#579
From: Waldek Hebisch
Date: Sun, 08 Nov 2026 04:37
77 lines
3953 bytes
Anton Ertl <anton@mips.complang.tuwien.ac.at> wrote:
> antispam@fricas.org (Waldek Hebisch) writes:
>>Anton Ertl <anton@mips.complang.tuwien.ac.at> wrote:
>>> 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.
>>
>>It must be more complex.  Silly fibonacci benchmark shows average
>>performance of function call per 2 clocks.
> 
> Without inlining?  On what hardware?
> 
> What I see on a Rocket Lake with a Fibonacci program compiled by the
> Rust 1.89 compiler is 3.6 cycles per return (i.e., also per call, with
> 2.3 branches per return).  I have not looked at the code to see if
> there is any inlining, but given that a regular fibonacci call
> includes a call, a conditional branch, and a return (with any
> recursive call accounted separately), showing 2.3 branches indicates
> that there is at least some inlining going on here.

A little correction.  This is on AMD Ryzen 9 7900 with claims
3.0 GHz clock.  But perf says that benchmark run at 5.310 GHz,
so number of clocks is larger.  I used two versions, one produced
by gcc -O which in assembly is:

fib:
        movq    %rdi, %rax
        cmpq    $1, %rdi
        jle     .L5
        pushq   %rbp
        pushq   %rbx
        subq    $8, %rsp
        movq    %rdi, %rbx
        leaq    -1(%rdi), %rdi
        call    fib
        movq    %rax, %rbp
        leaq    -2(%rbx), %rdi
        call    fib

So performs all expected calls.  This one needs 4.6 cycles
per call.  The other is generated by the perl program below.
Generated code contains only calls and returns, for each
n there is separate function.  Call structure is exactly the
same as when computing fibonacci.  This one needs 4.01
cycles per call.  For comparison, version which replaces
final call and ret by jump (corresponding to tail call
elimination) needs 2.43 clocks per "call".

-----------<cut here>---------------
print << 'EOD1';
        .file   "fib3c.pl"

EOD1

my($j);

for($j = 2; $j < 50; $j++) {
    my($k) = $j - 1;
    my($l) = $j - 2;
print << "EOD2";
        .globl  fib$j
        .type   fib$j, \@function
fib$j:
        call    fib$k
        call    fib$l
        ret
        .size   fib$j, .-fib$j
EOD2
}
-----------<cut here>---------------

-- 
                              Waldek Hebisch
Technical Details
Message-ID: <11couac$3eeoe$1@paganini.bofh.team>
Path: mbox-mo1.pugleaf.net!archive.usenet.blueworldhosting.com!usenet.blueworldhosting.com!diablo1.usenet.blueworldhosting.com!newsfeed.bofh.team!paganini.bofh.team!not-for-mail
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> <11cnj5a$36etq$1@paganini.bofh.team> <2026Nov7.190141@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!newsfeed.bofh.team!paganini.bofh.team!not-for-mail
From: antispam@fricas.org (Waldek Hebisch)
Newsgroups: comp.arch
Subject: Re: Register windows
Date: Sun, 8 Nov 2026 04:37:34 -0000 (UTC)
Organization: bofh.team Usenet service
Message-ID: <11couac$3eeoe$1@paganini.bofh.team>
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> <11cnj5a$36etq$1@paganini.bofh.team> <2026Nov7.190141@mips.complang.tuwien.ac.at>
Injection-Date: Sun, 8 Nov 2026 04:37:34 -0000 (UTC)
Injection-Info: paganini.bofh.team; logging-data="3619598"; 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