Article View: comp.arch
Article #764Re: Large constants in RISC
From: MitchAlsup
Date: Sun, 15 Nov 2026 19:04
Date: Sun, 15 Nov 2026 19:04
46 lines
2855 bytes
2855 bytes
anton@mips.complang.tuwien.ac.at (Anton Ertl) posted: > BGB <cr88192@gmail.com> writes: > >However, if counting clock-cycles, a prefix is a win: > > Prefix + Op: Zero cycle overhead for the missed constant; > > Load + Op: May add 3 or 4 clock cycles. > > > >So, would need to speculatively load the immediate values several > >instructions in advance, and hope that there are no extra cache misses. > > The nice thing about the load is that its address is usually available > right away. So the load operation is typically performed as soon as > possible, and for a sequence > > load r1, d(rct) > add r3=r1+r2 > > where rct is the register pointing to the constant table, the result > may be ready in r1 before r2 is ready. > > The bottom line is that this load typically does not cost latency. > > Concerning cache misses: If the code is executed often, the constant > will be in the (L1) D-Cache. If there is a cache miss, the code has > not been executed recently. Bottom line: Cache misses are rare, > because caches work. > > >This sort of thing can be a bigger saving though for things like > >accessing global variables (where the existing options "generally > >suck"). Typically, an unscaled Disp12 falls short of being able to > >directly address all of the commonly-used global variables in a typical > >program. > > How many globals does your program have. > > In order to be able to address the globals of a program with a single > global pointer, Or efficient access to large displacements which frees up the global pointer, > the linker needs to do quite a bit of work. Maybe the > RISC-V linker does. For the Alpha every compilation unit has its own > constant and global table as far as I remember (and I think the same > register is used for both on the Alpha). > > - anton
Technical Details
Message-ID:
<1794769473-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-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> <11dakku$29j9n$1@dont-email.me> <2026Nov15.170804@mips.complang.tuwien.ac.at>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> <11d9d0d$1rsce$1@dont-email.me> <11d9tq8$1b9c1$2@paganini.bofh.team> <11dabct$26fdl$1@dont-email.me> <11dahac$2t74$1@gal.iecc.com> <11dakku$29j9n$1@dont-email.me> <2026Nov15.170804@mips.complang.tuwien.ac.at> Date: Sun, 15 Nov 2026 19:04:33 GMT Mime-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Message-ID: <1794769473-5857@newsgrouper.org> Injection-Info: newsgrouper.org; mail-complaints-to="newsgrouper@yahoo.com"; posting-account=user5857 Injection-Date: Sun, 15 Nov 2026 19:04:33 GMT User-Agent: Newsgrouper/0.9.0