Jump to content
sakura

Buggy Optimizer in Delphi 10.4

Recommended Posts

Hi,

 

just for you guys to weigh in, we have located a bug in the Delphi 10.4 compiler, that removes a totally valid assign statement in RELEASE mode, believing, that the code will never be executed. 

 

The actual method is from the mORMot library in releases before last week (unit SynCommons.pas, method TSynAnsiFixedWidth.AnsiBufferToUTF8. A full discussion is available at the mORMot-Forum: https://synopse.info/forum/viewtopic.php?id=5520 .

 

I have reported the bug to Embarcadero: https://quality.embarcadero.com/browse/RSP-30088 .

 

Please check out my report and try to confirm and weigh in there. It should be reproducible.

 

---

 

Note, the compiler will tell you (Hint H2077), that the value assigned is never used and thus, in RELEASE mode, with optimizations enabled, drop the code completely.

 

Thanks for your time and support 👍

  • Thanks 3
  • Sad 1

Share this post


Link to post

As I see using GOTO it is good for optimization with nested loops to get from one level to another, while keeping loop condition simple. Never used it in Delphi I think. Covorker used in very heavy and nested looping to gain speed.

But is it always possible to write without goto as same performance. (Hard to give real life example on top of my head). In other words I can't figure out how you would restructure nested loops without including more complex looping condition... 

 

-Tee-

 

PS would be funny to rename goto GTFO 😄

Edited by Tommi Prami

Share this post


Link to post

Let's not discuss the GOTO - first, it is not my code, but code from a library I use, second, the full method from the library certainly benefits from it. It is not always possible to optimize for everything cleanly. For full details, follow the links 😉

Share this post


Link to post
5 hours ago, Tommi Prami said:

But is it always possible to write without goto as same performance. (Hard to give real life example on top of my head).

I challenge you to write this method in a more performant way than what it currently is without completely turning it into an even less readable mess:

https://bitbucket.org/sglienke/spring4d/src/534d63bccd0891d165d6cee1cbfff18df790661e/Source/Base/Spring.pas#lines-10122

Edited by Stefan Glienke

Share this post


Link to post

Although I avoid using Goto (and usually With as well) in my own code.  I appreciate the library writers who do whatever they can for performance or usability!  I think I still use the "super pos" function that was written for the old fastcode challege which has  a bunch of gotos and is amazingly fast.

  • Like 1

Share this post


Link to post
16 hours ago, Stefan Glienke said:

I challenge you to write this method in a more performant way than what it currently is without completely turning it into an even less readable mess:

https://bitbucket.org/sglienke/spring4d/src/534d63bccd0891d165d6cee1cbfff18df790661e/Source/Base/Spring.pas#lines-10122

Kind of my point exactly. I was just asking is there a way to restructure code away from GOTO.  I had just gut feeling that is not always possible or that easy...

Share this post


Link to post

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

×