🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: comp.arch
Article #743

Re: Large constants in RISC

#743
From: Robert Finch
Date: Sun, 15 Nov 2026 02:06
61 lines
4273 bytes
On 2026-11-14 7:57 p.m., Brian G. Lucas wrote:
> 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.
>
Tried something similar in another project and it worked but the code 
density was crpy. Constants were piled up at the end of a cache line 
then accessed with an offset stored in the instruction. The core tracked 
where the constants were and marked them as NOPs. A cache line always 
had to start with an 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: <11db445$2e6ih$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> <11db01q$2d5ee$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: Robert Finch <robfi680@gmail.com>
Newsgroups: comp.arch
Subject: Re: Large constants in RISC
Date: Sat, 14 Nov 2026 21:06:59 -0500
Organization: A noiseless patient Spider
Lines: 61
Message-ID: <11db445$2e6ih$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> <11db01q$2d5ee$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 02:07:02 +0000 (UTC)
Injection-Info: dont-email.me;
	logging-data="2562641"; mail-complaints-to="abuse@eternal-september.org";	posting-account="U2FsdGVkX19kOoHJws0lAY787966ZKPQYyfVLNt3dx8="; posting-host="fae696d39252189cccae6711aef1166b"
User-Agent: Mozilla Thunderbird
Cancel-Lock: sha1:LKNVrP+XRuaIm/OAggKxDqZAXcQ= sha256:PPScENny1WPWmRYtY0tb+o7epu4rE2LRFCZSHEziMAg=
	sha1:QgJNG4NnjDc/czzdIJToktIB+d8= sha256:1V0Ku+fiOYhzqOibkpjK9ogkD0STUCzaoOcFg6lYAEk=
Content-Language: en-US
In-Reply-To: <11db01q$2d5ee$1@dont-email.me>