[fpc-devel] Optimizer Overhaul Take 2... Jump Optimizations
J. Gareth Moreton
gareth at moreton-family.com
Thu Oct 31 05:57:14 CET 2019
Hi everyone,
So after my x86_64 optimizer overhaul was rejected in its current form,
I decided to set to work again in cleaner steps. The first thing I've
started to address are jump optimisations, since they gave notable
improvements that were independent of things lke the reduction in the
number of passes. There is also a bonus... a lot of it is
cross-platform too!
One thing I do need to do is to cross-compile to all known platforms...
I can only test a handful of the i386 and x86_64 platforms, but I want
to at least see if it compiles before I submit the patch for more
thorough testing. Does anyone have any tips or a sample script
(preferably a .BAT file) that cross-compiles from x86_64-win64 or
i386-win32 onto a reasonable set of platforms that at least gives me a
good smoke test? (Obviously, every combination is a little overkill if
impractical).
I'm trying to keep things as simple as possible, but for the best
optimisations, I had to introduce a new function for all platforms:
*function *condition_in(*const *c1, c2: TAsmCond): Boolean;
It is similar to "conditions_equal", but it returns true if c1 is a
subset of c2 (e.g. "C_E" and "C_L" are both subsets of "C_LE", but
"C_LE" is not a subset of "C_L"). It always returns True if c2 is
"C_None" (i.e. an unconditional jump) or if the conditions are equal,
but analysing the subsets is platform-specific. I've done the best I
can for the platform-specific assemblers that I don't know too well, but
I'll need someone to check them over and maybe improve them, since I
don't know what some of the conditions are. The function is mostly
failsafe, in that if it returns False, an optimisation won't be
performed. It's to help track final jump destinations more accurately,
as well as detect what I call 'dominated jumps' - for example:
jbe @lbl1
je @lbl2
The je instruction will never branch because the jbe instruction above
it will branch if the equality condition is met, so it can be safely
removed.
I'll run the win32 and win64 tests over Thursday and will submit the
patches once everything passes, as well as a PDF design and
implementation spec to explain what everything is as well as the
concepts of dominated jumps and the like.
Gareth aka. Kit
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.freepascal.org/pipermail/fpc-devel/attachments/20191031/97a3423d/attachment.html>
More information about the fpc-devel
mailing list