Recent

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

Xor-el

  • Sr. Member
  • ****
  • Posts: 404
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: 6090
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
The only true wisdom is knowing you know nothing

Thaddy

  • Hero Member
  • *****
  • Posts: 14201
  • Probably until I exterminate Putin.
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 »
Specialize a type, not a var.

jamie

  • Hero Member
  • *****
  • Posts: 6090
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.
The only true wisdom is knowing you know nothing

Xor-el

  • Sr. Member
  • ****
  • Posts: 404
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: 404
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: 5446
  • 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: 14201
  • Probably until I exterminate Putin.
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?
Specialize a type, not a var.

 

TinyPortal © 2005-2018