[fpc-devel] What exactly are the differences in what each of the "-Cp", "-Cf", and "-Op" command line flags enable as far as optimizations?
J. Gareth Moreton
gareth at moreton-family.com
Tue Sep 8 03:01:51 CEST 2020
The gist of it is that you're specifying the earliest CPU that your
program will run on (if it runs on an older CPU, it might crash with
SIGILL). -Cp dictates the instruction set version used overall, while
-Cf specifies the family of floating-point instructions that will be
used. Later versions of SSE have better rounding functions, for
example, although I think it's more applicable to i386 where the older
floating-point stack is used by default.
Generally you'd set -Cp and -Op to the same value, and I think -Op is
set to match -Cp if it's omitted. I might need Florian to confirm
though. I have programmed one or two optimisations that depend on the
value of -Op - the one that springs to mind is where a group of MOV
instructions are morphed into an XCHG instruction - XCHG is slower than
the 3 MOV instructions until relatively recently, so it won't perform
this optimisation by default unless optimising for size or if -Op is set
to a particular value (I think at least "CoreI").
When vectorisation starts making a proper appearance in the compiler,
I'll be very likely developing optimisations for fused multiply-add
(FMA), which only came about after AVX.
Gareth aka. Kit
On 08/09/2020 00:03, Ben Grasset via fpc-devel wrote:
> For example, a valid FPC command line would be:
> fpc -O3 -CfAVX2 -CpCOREAVX2 -OpCOREAVX2 file.pas
> To what extent is each of those flags enabling the generation of AVX2
> instructions? Are they all necessary, or does their functionality
> overlap to some degree? Which is most important?
> fpc-devel maillist - fpc-devel at lists.freepascal.org
This email has been checked for viruses by Avast antivirus software.
-------------- next part --------------
An HTML attachment was scrubbed...
More information about the fpc-devel