Sign in Join

Live chat for Free Pascal, Lazarus, Delphi and every Pascal programmer.

Mailing lists / fpc-devel / 2022-09

What's the difference between -Cp and -Op?

3 messages · 2 people ·

Reply by email Subscribe to this list Your subscription

Read-only archive. Use j and k to move between messages.

J. Gareth Moreton

Hi everyone,

So this one has eluded me a little bit... what's the exact difference between the -Cp and -Op options?  I figure it's for specific features on non-Intel processors, but when building code for AVX2, for example, I tend to specify "-CpCOREAVX2 -OpCOREAVX2 -CfAVX2".  If the code generator creates AVX2 though, normally I'd want the peephole optimizer to make improvements where it can, but forgetting -OpCOREAVX2 may cause them to be ignored.

Gareth aka. Kit

Reply by email

Jonas Maebe
to J. Gareth Moreton
J. Gareth Moreton wrote
So this one has eluded me a little bit... what's the exact difference between the -Cp and -Op options?

-Cp: the code is only guaranteed to run on this cpu and usually also later ones (the code generator/optimiser can use instruction that are not available on earlier/other cpus). E.g.: use BMI2 instructions. -Op: the code is optimised for this cpu, but will still run on earlier/later ones. E.g., use lea instead of shl on a particular cpu because it's faster there, even if it's not the case on all of them. -Cf: use this instruction set to perform floating point calculations. It is independently handled from the two previous settings, even if it can indirectly also influence the minimum required CPU.

Jonas

Reply by email

J. Gareth Moreton
to Jonas Maebe

Aah, that's useful information, especially the lea/shl example. Thanks Jonas.

Ideally -Op shouldn't be set to an architecture that's older than the one for -Cp (i.e. optimising for a processor that's older than the minimum type it's guaranteed to run on), but is it possible to actually do so?

Gareth aka. Kit

Jonas Maebe wrote 22 lines
On 2022-09-07 16:34, J. Gareth Moreton via fpc-devel wrote: > So this one has eluded me a little bit... what's the exact difference > between the -Cp and -Op options? -Cp: the code is only guaranteed to run on this cpu and usually also later ones (the code generator/optimiser can use instruction that are not available on earlier/other cpus). E.g.: use BMI2 instructions. -Op: the code is optimised for this cpu, but will still run on earlier/later ones. E.g., use lea instead of shl on a particular cpu because it's faster there, even if it's not the case on all of them. -Cf: use this instruction set to perform floating point calculations. It is independently handled from the two previous settings, even if it can indirectly also influence the minimum required CPU. Jonas _______________________________________________ fpc-devel maillist  -  https://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-devel

Reply by email