[fpc-devel] x86_64 Optimizer Overhaul

J. Gareth Moreton gareth at moreton-family.com
Sun Dec 23 22:09:31 CET 2018


 Updated https://bugs.freepascal.org/view.php?id=34628 - new
"overhaul-mov-refactor.patch" that now changes "movl addl movq" to "addl"
(and equivalently with "incl").  Currently the patches only apply to
x86_64, but i386 is ready for upload if approved... much less splitting
involved!

 Gareth aka. Kit
 P.S. To the moderators... I believe there's a message in the moderation
queue because it contains a 60kb attachment (a patch file).

 On Sat 22/12/18 20:28 , "J. Gareth Moreton" gareth at moreton-family.com
sent:
  Saying that, it might not be a bug but a design choice.  If the compiler
is able to extend the variable to 64 bits on the stack, it will do,
including the use of "incq" over "incl" - whenever I try to exploit the
upper 32 bits, the compiler is too smart for that!

 The only problem is that it can hinder the peephole optimiser, and if I
put in an exception that optimises, say, "movl addl movq" to "addl" or
"incl" or whatnot, then that could be exploited.  I'll have a think in
regards to what to do with that one.

 Gareth aka. Kit

 On Sat 22/12/18 20:04 , "J. Gareth Moreton" gareth at moreton-family.com
sent:
  Have to apologise again for my web client making life difficult for the
mail archive system.

 Currently I'm a little reluctant to put in the "incq" fix because the code
isn't equivalent.  More than anything, it's a very minor bug with the node
system in that it writes the full 64-bit register instead of the 32-bit
register for LongInts and LongWords, it seems.  I might be able to exploit
the bug in a very narrow range of circumstances, and if I'm able to make a
reproducible test case, I'll report it.

 Nevertheless, if I'm not able to exploit it, it's something that might be
worth fixing if only because it will make optimisation easier and correct.

 Also note that "INC" is generally only generated if you're optimising for
size, because modern CPUs work better with "ADD" due to how it modifies the
RFLAGS register.

 For the overhaul in general, I have it ported over to i386 on my working
branch, since I've got x86_64 working without any breaking bugs.

 Even if just for a temporary debugging measure, I'm considering options to
allow the writing of node trees to an XML file or some such, since I think
this will allow easier debugging of that part of the compiler.

 Gareth aka. Kit
  _______________________________________________
 fpc-devel maillist - fpc-devel at lists.freepascal.org
 http://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-devel
[1]">http://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-devel

  _______________________________________________
 fpc-devel maillist - fpc-devel at lists.freepascal.org
 http://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-devel
[2]">http://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-devel

 

Links:
------
[1] http://secureweb.fast.net.uk/ http:=
[2] http://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-devel
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.freepascal.org/pipermail/fpc-devel/attachments/20181223/354d4258/attachment.html>


More information about the fpc-devel mailing list