🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: comp.arch
Article #734

Re: Large constants in RISC

#734
From: John Levine
Date: Sat, 14 Nov 2026 20:46
34 lines
2520 bytes
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.

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.


-- 
Regards,
John Levine, johnl@taugh.com, Primary Perpetrator of "The Internet for Dummies",
Please consider the environment before reading this e-mail. https://jl.ly
Technical Details
Message-ID: <11dahac$2t74$1@gal.iecc.com>
Path: mbox-mo1.pugleaf.net!news-lax.pugleaf.net!srv.newsdeef.eu!weretis.net!feeder9.news.weretis.net!news.misty.com!news.iecc.com!.POSTED.news.iecc.com!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>

Show Full Headers
Complete Article Headers
Path: mbox-mo1.pugleaf.net!news-lax.pugleaf.net!srv.newsdeef.eu!weretis.net!feeder9.news.weretis.net!news.misty.com!news.iecc.com!.POSTED.news.iecc.com!not-for-mail
From: John Levine <johnl@taugh.com>
Newsgroups: comp.arch
Subject: Re: Large constants in RISC
Date: Sat, 14 Nov 2026 20:46:04 -0000 (UTC)
Organization: Taughannock Networks
Message-ID: <11dahac$2t74$1@gal.iecc.com>
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>
MIME-Version: 1.0
Content-Type: text/plain; charset=utf-8
Content-Transfer-Encoding: 8bit
Injection-Date: Sat, 14 Nov 2026 20:46:04 -0000 (UTC)
Injection-Info: gal.iecc.com; posting-host="news.iecc.com:2001:470:1f07:1126:0:676f:7373:6970";
	logging-data="95460"; mail-complaints-to="abuse@iecc.com"
In-Reply-To: <11d76uq$11cdc$1@paganini.bofh.team> <11d9d0d$1rsce$1@dont-email.me> <11d9tq8$1b9c1$2@paganini.bofh.team> <11dabct$26fdl$1@dont-email.me>
Cleverness: some
X-Newsreader: trn 4.0-test77 (Sep 1, 2010)
Originator: johnl@iecc.com (John Levine)