From Newsgroup: comp.lang.forth
In article <877bksdpui.fsf@debian>,
Kragen Javier Sitaker <
kragen@canonical.org> wrote:
albert@spenarnc.xs4all.nl writes:
If a word is optimised it is totally inlined.
As well as being a powerful optimization in its own right, I am guessing
that that opens up a lot of opportunities for the stack-manipulation- >annihilation optimization you were talking about in your previous post.
[...]
I got to the point that the original (unadulterated to favor
a particular compiler) Byte benchmark performed in the league
of mpe Forth.
ThatrCOs very impressive!
Note that this is a rigged benchmark. All optimisations were
inspired by the Byte sieve.
I have 106 peephole patterns, some quite complicated.
How confident are you that all 106 are correct?
Not very. I took precautions however. REGRESS is a sort of a
compile time ASSERT, an alternative for strong typing.
If a REGRESS fails, the compilation fails.
This is an example. It takes myself half an hour to
understand the meticulous comment. All peep hole
optimisation lean heavily on my disassembly that turns
one assembler instruction into a list of component objects.
.code prints out the optimisation result that is manually
inspected if need be.
optimisation is a class that takes three parameters.
movimoviq-pattern is an object.
\ A movi reg, is up till now during optimisation has a 32 bit value.
\ That works as long as there is no ghost register, because the Q:
\ prefix is removed. For those cases where the immediate value must be 64 bit, \ this expansion is needed in the compression phase.
<! !Q MOVI|X, !!T 0 {L,} ~!!T !>
<A Q: MOVI|X, 0 , !TALLY A>
{ bufv 2 + L@ L>S bufc 2 + !
bufv C@ bufc OR!U
bufv 1+ C@ bufc 1+ OR!U
}
optimisation movimoviq-pattern
REGRESS movimoviq-pattern DUMPO S:
REGRESS original matches? S: TRUE
REGRESS original 1+ matches? S: FALSE
REGRESS HERE Q: MOVI|X, BX| 1234 IL, matches? S: TRUE
\ :" move is needs 64bits data"
: movimoviq-okay bufv get1-reg-QN 7 > ;
REGRESS HERE Q: MOVI|X, DX| 1 IL, matches? movimoviq-okay S: TRUE FALSE REGRESS HERE Q: MOVI|X, AX| 0 IL, matches? movimoviq-okay S: TRUE FALSE REGRESS HERE QN: MOVI|X, AX| 0 IL, 0 {L,} matches? movimoviq-okay S: TRUE TRUE
\ Optional replace, leave " was replaced".
: ?movimoviq-replace? movimoviq-okay DUP IF replace THEN ;
REGRESS HERE QN: MOVI|X, DI| 1234 IL, matches? S: TRUE
REGRESS ?movimoviq-replace? bufv$ @ S: TRUE 6
REGRESS bufc$ $@ .code bufc$ @ S: 10
This example illustrates why I gave up.
[...]
I decided to give up on i86 and concentrate on RISCV.
This kind of thing seems like it could be a significant advantage for
RISC-V, if people find that the cost-benefit ratio for writing compilers
for it is better than for 8086, i386, or amd64 (not sure which ISA you
meant by rCLi86rCY).
My compiler source for Intel is generic. It is adjusted by macros for
8086, 80386 and amd64 (and for linux windows etc.)
The optimiser handles amd64 primarily.
Kragen
--
The Chinese government is satisfied with its military superiority over USA.
The next 5 year plan has as primary goal to advance life expectancy
over 80 years, like Western Europe.
--- Synchronet 3.22a-Linux NewsLink 1.2