Recent

Author Topic: How to disable a particular optimization in a particular optimization level  (Read 243 times)

Xor-el

  • Sr. Member
  • ****
  • Posts: 384
Hi.
I want to know if there is a way to exclude a particular optimization at a particular optimization level in FPC.
Background
I was working on a particular codebase of mine in FPC 320 Fixes and I discovered an issue with a particular optimization, USELOADMODIFYSTORE to be precise.
When this particular optimization is enabled, it tends to slow down my code by a particular factor and at worse produce incorrect results when used in combination with other processor specific optimization like -CpCoreAVX2 and -OpCoreAVX2.
Now the problem here is that this particular optimization USELOADMODIFYSTORE is enabled by default in -O3 level optimization.
So back to my question, is there any way to exclude this particular optimization at this level other than having to use a lower optimization level, say -O2 and manually add other specific optimizations I want to maybe an .inc or my source file?

jamie

  • Hero Member
  • *****
  • Posts: 2168
It would be better if you could generate a minimum example of this PARTICULAR issue as a debugging example to fix the compiler and not work around this PARTICULAR problem you are facing.

 because in the end, I believe this PARTICULAR compiler is being used for 3.3.1 development and it could aid them reducing problems.  :D
Number 1 at blue screen app creations!

Thaddy

  • Hero Member
  • *****
  • Posts: 9293
Better to give a real anser:
{$optimization  USELOADMODIFYSTORE off}
See  https://freepascal.org/docs-html/current/prog/progsu58.html#x65-640001.2.58
That is the older documentation - and does not refer to this particular optimization  :-X -  because it is new, but will work in 3.2.0. because the mechanism is the same.
Luckily I happen to know OP perfectly understands me.
« Last Edit: November 16, 2019, 05:21:37 pm by Thaddy »
also related to equus asinus.

jamie

  • Hero Member
  • *****
  • Posts: 2168
I gave a real answer!. If you have a failing feature in a tool and this tool is being used to develop other tools don't you think this is the most opportune time to take advantage of it ?

 If this is a real bug then maybe it should be reported.
Number 1 at blue screen app creations!

Xor-el

  • Sr. Member
  • ****
  • Posts: 384
It would be better if you could generate a minimum example of this PARTICULAR issue as a debugging example to fix the compiler and not work around this PARTICULAR problem you are facing.

 because in the end, I believe this PARTICULAR compiler is being used for 3.3.1 development and it could aid them reducing problems.  :D

While this is true, generating a minimal example for this problem is no easy feat and it will take sometime.
Would love to do it though.

Xor-el

  • Sr. Member
  • ****
  • Posts: 384
Better to give a real anser:
{$optimization  USELOADMODIFYSTORE off}
See  https://freepascal.org/docs-html/current/prog/progsu58.html#x65-640001.2.58
That is the older documentation - and does not refer to this particular optimization  :-X -  because it is new, but will work in 3.2.0. because the mechanism is the same.
Luckily I happen to know OP perfectly understands me.
Splendid, exactly what I needed Thaddy.
Thanks once again for coming to the rescue.

PascalDragon

  • Hero Member
  • *****
  • Posts: 726
  • Compiler Developer
Better to give a real anser:
{$optimization  USELOADMODIFYSTORE off}
See  https://freepascal.org/docs-html/current/prog/progsu58.html#x65-640001.2.58
That is the older documentation - and does not refer to this particular optimization  :-X -  because it is new, but will work in 3.2.0. because the mechanism is the same.
Luckily I happen to know OP perfectly understands me.
jamie's reply is definitely important as well, cause if we don't know about a problem then we can't fix it and it will be in the compiler for a long time then.
« Last Edit: November 18, 2019, 09:19:51 am by PascalDragon »

Thaddy

  • Hero Member
  • *****
  • Posts: 9293
jamie's reply is definitely important as well, cause if we don't know about a problem then we can't fix it and it will be in the compiler for a long time then.
Yes, but the real answer was easy. So why didn't it show up?
also related to equus asinus.