Path: csiph.com!eternal-september.org!feeder.eternal-september.org!nntp.eternal-september.org!.POSTED!not-for-mail From: Kragen Javier Sitaker Newsgroups: comp.lang.forth Subject: Re: First result in riscv optimiser Date: Tue, 08 Sep 2026 02:21:32 -0300 Organization: Primarily biological and memetic Lines: 40 Message-ID: <87y0dcgvxf.fsf@debian> References: <2026Sep1.173341@mips.complang.tuwien.ac.at> <87ecf96ljg.fsf@debian> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit Injection-Date: Tue, 08 Sep 2026 05:23:50 +0000 (UTC) Injection-Info: dont-email.me; logging-data="4099120"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX19DqYA3YmL3CXU03n8p+C+D"; posting-host="d8b2792e0f4b3d7e1e2ac925ec3696b1" User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/28.2 (gnu/linux) Cancel-Lock: sha1:yG8gX3fXuvGP5Z+hmWuHgu0AT3c= sha1:76ajvfPV574SoDwbkb962HwiUrs= sha256:ZQbQpUhol7RM31xJdd/63kHDHXsVLlwz/4vyz41jnWQ= sha1:Q9OnCH5xUcvp2T43fe3ubOBr0ro= sha256:5VHuVl/9z/4FkIAxV9wny3W6CKbz8uc7L/iD1eUR3/Y= Xref: csiph.com comp.lang.forth:135600 albert@spenarnc.xs4all.nl writes: > In article <87ecf96ljg.fsf@debian>, > Kragen Javier Sitaker wrote: >>anton@mips.complang.tuwien.ac.at (Anton Ertl) writes: >>> (...) in general I don't think that full constant folding will trigger >>> often, (...) >> >>This is contextual. (...) > > You bet it is. > This is a test of the optimiser for i86 (that is unfinished but > partly working) > ------------------------------------- > \ Test of annihilating. > : test6 BASE @ IF SWAP THEN 2DROP ; > > ... > > : test6 > DROP DROP > ; > > After inlining of code words: > > POP|X, AX| > POP|X, AX| This is not quite constant folding, but it’s a related optimization. I don’t remember if it has an accepted name — it’s close to register allocation, but of course you aren’t allocating any registers. Clearly it makes a great improvement in `test6`. However, how does such code arise? You surely wouldn’t intentionally write it that way in production code. Conditional compilation with [ifdef] and the like? Subroutine inlining? That is, this kind of optimization can be extremely powerful — but generally only in synergy with other optimizations which create opportunities for it. Kragen