🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: comp.arch
Article #778

Re: Large constants in RISC

#778
From: BGB
Date: Mon, 16 Nov 2026 11:09
67 lines
3764 bytes
On 11/16/2026 2:04 AM, Anton Ertl wrote:
> BGB <cr88192@gmail.com> writes:
>> Or, if one happens to use something like a rarely-used global variable
>> (in the static-count sense) in the middle of a loop in the middle of the
>> hot path (which is where this sort of thing is seemingly most prone to
>> show up sometimes).
>>
>> So, sometimes it is better to be defensive and mostly address the last
>> few percent as a precautionary effort against slow-cases randomly
>> showing up in the hot path.
>>
>>
>> Well, at least excluding programmer-level "everyone already knows this
>> is slow" things, like integer divide and modulo.
>>
>>
>> Pretty much everyone seems to expect things like integer constants and
>> global variables to be nearly free though.
> 
> What makes you think that everybody expects accesses to global
> variables to be fast?
> 

There is a lot of code around that seems to keep a lot of active state 
in global variables (rather than using structs or passing stuff using 
function arguments).

Say, for example, most of the configuration state for drawing spans and 
columns in the Doom style engines, etc.

They probably wouldn't have done it this way if they expected global 
variables to be slow.


Well, most extreme example being the "Build Engine" (from Apogee / 3D 
Realms), but, errm, I haven't really felt up to trying to port this.


> Certainly my take has been for decades that anything that's not in
> registers is slow.  And that global variables are not in registers, in
> general.
> 

Well, admittedly a fair amount of the code I am dealing with was 
originally written in decades past.


But, admittedly, some of the code I had used as my major test cases, was 
actually code I had tried (and initially failed) to understand when I 
was learning programming back in elementary school.

So, it is possible that things like Doom and similar don't reflect 
particularly modern programming sensibilities.



And, to admit, I more often put everything into big structs and pass 
pointers to the structs around in function arguments.

Usually this is because it is often nice to be able to have multiple 
instances of things, which doesn't work so well when everything is held 
in global variables.


> - anton

Technical Details
Message-ID: <11deo9m$3g047$2@dont-email.me>
Path: mbox-mo1.pugleaf.net!news-lax.pugleaf.net!news.tcpreset.net!newsfeed.bofh.team!eternal-september.org!feeder.eternal-september.org!nntp.eternal-september.org!.POSTED!not-for-mail
References: <11d76uq$11cdc$1@paganini.bofh.team> <11d9d0d$1rsce$1@dont-email.me> <11d9tq8$1b9c1$2@paganini.bofh.team> <11dabct$26fdl$1@dont-email.me> <11dahac$2t74$1@gal.iecc.com> <1794768602-5857@newsgrouper.org> <11dd91o$33nqv$1@dont-email.me> <2026Nov16.090453@mips.complang.tuwien.ac.at>

Show Full Headers
Complete Article Headers
Path: mbox-mo1.pugleaf.net!news-lax.pugleaf.net!news.tcpreset.net!newsfeed.bofh.team!eternal-september.org!feeder.eternal-september.org!nntp.eternal-september.org!.POSTED!not-for-mail
From: BGB <cr88192@gmail.com>
Newsgroups: comp.arch
Subject: Re: Large constants in RISC
Date: Mon, 16 Nov 2026 05:09:40 -0600
Organization: A noiseless patient Spider
Lines: 67
Message-ID: <11deo9m$3g047$2@dont-email.me>
References: <11d76uq$11cdc$1@paganini.bofh.team>
 <11d9d0d$1rsce$1@dont-email.me> <11d9tq8$1b9c1$2@paganini.bofh.team>
 <11dabct$26fdl$1@dont-email.me> <11dahac$2t74$1@gal.iecc.com>
 <1794768602-5857@newsgrouper.org> <11dd91o$33nqv$1@dont-email.me>
 <2026Nov16.090453@mips.complang.tuwien.ac.at>
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8; format=flowed
Content-Transfer-Encoding: 7bit
Injection-Date: Mon, 16 Nov 2026 11:09:42 +0000 (UTC)
Injection-Info: dont-email.me;
	logging-data="3670151"; mail-complaints-to="abuse@eternal-september.org";	posting-account="U2FsdGVkX1917+D27GBT3pKPlRVrMEvaxerSiV9hOCI="; posting-host="7cb72988303a6b52400f6abc3a774d75"
User-Agent: Mozilla Thunderbird
Cancel-Lock: sha1:BOBPFUQiErH1aWEfzc9zi+vJSEM= sha256:6IJF1MB45wyskuTUtmP990ZtBYwuA//zgIMt+vRV0r4=
	sha1:ZRdGiwNGNNFy49wNmMa/tkyPl6s= sha256:2/LWbJWVoFH5GmG4mcPIExMWovVJhw2caxrKB/Q4I/w=
Content-Language: en-US
In-Reply-To: <2026Nov16.090453@mips.complang.tuwien.ac.at>