[fpc-devel] x86_64/amd64 asmcse and peephole optimizer port
Jonas Maebe
jonas.maebe at elis.ugent.be
Wed Nov 10 14:27:28 CET 2010
On 30 Oct 2010, at 13:20, Matthias K. wrote:
> the last days I've done a first step in Porting the i386 data flow
> analyzer, asmcse and peephole optimizations.
Quite impressive!
> Main motivation is: target instruction level optimization is always a
> good thing especially for bottlenecks.
That's true. There's one small problem though: the asmcse optimiser
(csopt386, and large parts of daopt386) has been on its way out the
last couple of releases, because it contains some bugs that are very
hard to fix due to it not being very good/clean code. It is already no
longer activated by default for -O2 since FPC 2.4.0, and currently has
to be enabled explicitly via -Ooasmcse.
The final drop in the bucket that caused it to be disabled by default
was http://bugs.freepascal.org/view.php?id=14363
> The main target was: porting the i386 optimization part to x86_64
> (amd64) and merging it back such that generic x86 optimization is in
> one place.
If you are willing to take responsibility for that code (feel free to
completely rewrite it), that would be great. Then it can maybe be
enabled again by default.
> This is currently not complete, i didn't merge it back since there is
> still testing and review todo. But from the current point of view it
> should be rather simple to to merge the data flow analysis and the
> asmcse parts. The peephole part is another point, that should be pure
> cpu/target specific.
I guess there are some common ones there as well, no? (especially
regarding mov's and jump chaining).
> Like I stated above, the current approach needs further testing (fpc
> testsuite returns same result for patched and unpatched compiler with
> "make full", but there may be things missing) and review from others
> (hopefully with more knowledge about the x86_64 code generator part
> and potential optimizations). Thats why I'm attaching my current
> approach here.
At first look, I think it's ok except for the indentation. Please use
the same style as the original code (e.g., indenting "begin" after
"if ..."). See http://wiki.freepascal.org/Coding_style for some more
info.
> TODO: There is potential for further optimizations, especially for x87
> and 128bit Media/XOP/FM4.. but the code needs some cleanups before and
> possibly some bug fixes
>
> I'm open for any feedback, bugfixes and so on (and if it should be
> merged with i386 parts)
Merging with i386 is fine! The whole assembler optimiser
infrastructure is also quite independent from the rest of the
compiler, which makes it a very good way to get started (it's how I
rolled into FPC development in 1997, which is in large part why the
code's organisation is so bad :)
Jonas
More information about the fpc-devel
mailing list