🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: comp.arch
Article #729

Re: Large constants in RISC

#729
From: MitchAlsup
Date: Sat, 14 Nov 2026 19:06
54 lines
3007 bytes
Terje Mathisen <terje.mathisen@tmsw.no> posted:

> Waldek Hebisch wrote:
> > Terje Mathisen <terje.mathisen@tmsw.no> wrote:
> >> Waldek Hebisch wrote:
----------------------------
> > If you assume that your constants are 64 bit or very short, then
> > prefix looks better.  However, pretty frequent case are not so
> > small constants that fits into 28 bits.  Basically, calls need
> > addresses and they go semi-random in given library.  28 bit is
> > enough for most libraries (and can be effectively increased by
> > 2 bits if one assumes 4 byte alignment for the target), while
> > 12 or even 16 bit offsets are too short.

28-bits (26-bits<<2) is fine only for statically linked modules.
 
> > So this covers constants of various length, with smaller cost
> > for smaller constants.  I was mainly looking at integer case.
> > For FPU use some constants may be represented in single precision
> > and converted to doubles, but nontrivial fraction of double
> > constants will need full 64 bits.  OTOH it is not clear to
> > me how much one gains thanks to 64 bit floating point constants.
> > IME precomputed constants are frequently kept in tables, it
> > is not clear to me if there could be significant gain from
> > putting them into instructions.

If/when your polynomial code looks like::

          LD     Rt,[&constant1]
          FMAC   Rs,Rr,Rt,Rs
          LD     Rt,[&constant2]
          FMAC   Rs,Rr,Rt,Rs

you save 50% of the instructions as:

          FMAC   Rs,Rr,#constant1,Rs
          FMAC   Rs,Rr,#constant2,Rs

And you avoid DCache pollution.
 
> Ask Mitch!
> 
> Seems he's getting very consistent gains from having 32 and 64-bit 
> immdiates as part of the instruction stream, one of the major ones
> being no cache misses when loading said constant.

If you count 70% of the instruction count as my gain of 30%, on average,
large constants are 10%-12% of that 30%.

If you look at the tabulations in H&P you can derive a similar number
1st edition would give 9%-ish for a 32-bit architecture {after you do
some massaging of the table data}}
> 
> Terje
Technical Details
Message-ID: <1794683180-5857@newsgrouper.org>
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!newsgrouper.org!.POSTED!not-for-mail
References: <11d76uq$11cdc$1@paganini.bofh.team> <11d7ct8$17akn$1@dont-email.me> <11d7ih2$11orr$1@paganini.bofh.team> <11d9d0d$1rsce$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!newsgrouper.org!.POSTED!not-for-mail
From: MitchAlsup <user5857@newsgrouper.org.invalid>
Newsgroups: comp.arch
Subject: Re: Large constants in RISC
References: <11d76uq$11cdc$1@paganini.bofh.team>
  <11d7ct8$17akn$1@dont-email.me> <11d7ih2$11orr$1@paganini.bofh.team> <11d9d0d$1rsce$1@dont-email.me>
Date: Sat, 14 Nov 2026 19:06:20 GMT
Mime-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
Message-ID: <1794683180-5857@newsgrouper.org>
Injection-Info: newsgrouper.org; mail-complaints-to="newsgrouper@yahoo.com"; posting-account=user5857
Injection-Date: Sat, 14 Nov 2026 19:06:20 GMT
User-Agent: Newsgrouper/0.9.0