🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: comp.arch
Article #739

Re: Large constants in RISC

#739
From: Brian G. Lucas
Date: Sun, 15 Nov 2026 00:57
52 lines
3790 bytes
On 11/14/26 6:38 PM, Robert Finch wrote:
> On 2026-11-14 3:46 p.m., John Levine wrote:
>> It appears that BGB  <cr88192@gmail.com> said:
>>>> I read what he wrote and I do not doubt that code having constants
>>>> in instructions is faster.  What is not clear how frequently
>>>> code with explicit constants appears in real life.
>>>>
>>>
>>> It depends, for 3RI forms IME:
>>>    ~ 93% .. 96% fit in 10 bits;
>>>    ~ 95% .. 98% fit into 12 bits.
>>>
>>> Of those that miss, there is a clustering patters:
>>>    Big spike near 16 bits;
>>>    Another smaller spike near 32 bits;
>>>    Very little else up until around 64 bits.
>>>
>>> The vast majority fall along a "near zero" curve, with a fairly steep
>>> falloff. ...
>>
>> That tells me that it's not a good use of instruction bits to try to
>> encode large constants. For the 3% of constants that can't be encoded
>> in 12 bits, use a constant pool.
> 
> One ends up with constants in the data cache. May be slower than having 
> constants inline from the I$. One thought it to have instructions that can 
> load constants using the I$.
> 
No. No. No. In MCore the constants were loaded from an offset in the 
instruction stream.  The constants were placed after an unconditional branch 
which terminated a basic block. Often the instructions were in i-cache that 
had already been loaded in order to execute the basic block.  Not exactly 
free, but often so.  All MCore instructions were 16-bits, and only 8-bit (or 
later 7-bit) immediates were encoded in the instruction.

> Qupls wastes about 3% of the opcode space for constant postfixes.
> The constant decoder is maybe a little disproportionate to its value.
>>
>> FYI, that's basically what S/360 did.  The load address instruction
>> has a 12 bit immediate field  you can use to load 12 bit constants,
>> other than that you're on your own.  S/390 added a load immediate with
>> a 16 bit signed value, z added load immediates with a 32 bit operand,
>> and versions that load the high or low halves of a regster, so with
>> two 48-bit instructions you can load any 64 bit value.
>>
>>
> PowerPC uses shifted immediate instructions. IIRC there were four of them. ARM 
> has shifted constant instruction too. For Qupls it was an option at one point.
> 
> Shifted immediate instructions are appealing as they can stick with the same 
> instruction size.
Technical Details
Message-ID: <11db01q$2d5ee$1@dont-email.me>
Path: mbox-mo1.pugleaf.net!news-lax.pugleaf.net!srl.newsdeef.eu!news.hispagatos.org!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> <11dauv4$2csdn$1@dont-email.me>

Show Full Headers
Complete Article Headers
Path: mbox-mo1.pugleaf.net!news-lax.pugleaf.net!srl.newsdeef.eu!news.hispagatos.org!eternal-september.org!feeder.eternal-september.org!nntp.eternal-september.org!.POSTED!not-for-mail
From: "Brian G. Lucas" <bagel99@gmail.com>
Newsgroups: comp.arch
Subject: Re: Large constants in RISC
Date: Sat, 14 Nov 2026 18:57:28 -0600
Organization: A noiseless patient Spider
Lines: 52
Message-ID: <11db01q$2d5ee$1@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>
 <11dauv4$2csdn$1@dont-email.me>
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8; format=flowed
Content-Transfer-Encoding: 8bit
Injection-Date: Sun, 15 Nov 2026 00:57:31 +0000 (UTC)
Injection-Info: dont-email.me;
	logging-data="2528718"; mail-complaints-to="abuse@eternal-september.org";	posting-account="U2FsdGVkX1+82Vh+AJ4Qhg/AXkeKvPy3"; posting-host="d9a3739609581d16c553a375bf746461"
User-Agent: Mozilla Thunderbird
Cancel-Lock: sha1:QvFW/z0wif0Th5ucui82ExFYl1I= sha256:4GBCEORMR8BFAFFCAgf5D8Wj9hPXafwOp0vsTsKz2wA=
	sha1:kjzf1jldsXsOW8ZPjo3JoqsGypc= sha256:jhKQJfiw8WegmHUryleI4edaanjLf5QPySALFj69LHM=
Content-Language: en-US
In-Reply-To: <11dauv4$2csdn$1@dont-email.me>