Article View: comp.arch
Article #738Re: Large constants in RISC
From: Robert Finch
Date: Sun, 15 Nov 2026 00:38
Date: Sun, 15 Nov 2026 00:38
48 lines
3219 bytes
3219 bytes
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$. 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:
<11dauv4$2csdn$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-mailReferences:
<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>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 19:38:58 -0500 Organization: A noiseless patient Spider Lines: 48 Message-ID: <11dauv4$2csdn$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> MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit Injection-Date: Sun, 15 Nov 2026 00:39:01 +0000 (UTC) Injection-Info: dont-email.me; logging-data="2519479"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX19UbF0P5ZL2ozabB0c/0AXyhjr2EB/M1Bc="; posting-host="fae696d39252189cccae6711aef1166b" User-Agent: Mozilla Thunderbird Cancel-Lock: sha1:ZkkaGEYcZQohMFrWAY3tw/b57AU= sha256:mTyka8LMF8iT+aeBpN8dCyOh/nwgD4dZME6qKuJgf3Q= sha1:VEkJZXv8D23xltVesqaxi49bV+g= sha256:x3SyXNOgjyhOd2fha2EHHzMvAbTO0cli/l9iDioQFu0= Content-Language: en-US In-Reply-To: <11dahac$2t74$1@gal.iecc.com>