Article View: comp.arch
Article #753Re: Large constants in RISC
From: Anton Ertl
Date: Sun, 15 Nov 2026 16:08
Date: Sun, 15 Nov 2026 16:08
43 lines
3012 bytes
3012 bytes
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, 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 -- 'Anyone trying for "industrial quality" ISA should avoid undefined behavior.' Mitch Alsup, <c17fcd89-f024-40e7-a594-88a85ac10d20o@googlegroups.com>
Technical Details
Message-ID:
<2026Nov15.170804@mips.complang.tuwien.ac.at>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> <11dakku$29j9n$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: anton@mips.complang.tuwien.ac.at (Anton Ertl) Newsgroups: comp.arch Subject: Re: Large constants in RISC Date: Sun, 15 Nov 2026 16:08:04 GMT Organization: Institut fuer Computersprachen, Technische Universitaet Wien Lines: 43 Message-ID: <2026Nov15.170804@mips.complang.tuwien.ac.at> 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> Injection-Date: Sun, 15 Nov 2026 16:27:47 +0000 (UTC) Injection-Info: dont-email.me; logging-data="3018563"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX19Gzbhmv5qUNgiPJls/2wSZ"; posting-host="c546d9c3efc054d217948ebb9c0ff5c8" Cancel-Lock: sha1:qFNpcovU6X7sjAMNe7Rfdtm8u4M= sha256:UyxMR5Kwat4YemRKCoAB8an9/VRoHZEWd8en2fGJnyw= sha1:sr6o2ONUXGIqTFR7z5z7ruaRwLg= sha256:RAk7Zf2UGOILmEOfmvP0J7p/PP5x8mhVwcY+Bu+5x+Q= X-newsreader: xrn 10.11