Attila Kovacs 629 Posted March 23, 2021 Am I the only one annoyed that these are in System.Math? 4 Share this post Link to post
Guest Posted March 23, 2021 Perhaps, since you must have been born with this "gift" :))) Know that, since Delphi 2, Delphi already had problems with Min and Max procedure - at the time, Borland's manager, had switched roles, that is, Min did Max and Max did Min. hug Share this post Link to post
Attila Kovacs 629 Posted March 23, 2021 I have no idea what you are talking about. Those were MinValue and MaxValue. I'm really struggling to find any sense in any of your comments. 1 1 Share this post Link to post
Guest Posted March 23, 2021 did know that the "structures" seems dont have changed until today? same "DATA array" same > and < use hug Share this post Link to post
KodeZwerg 54 Posted March 23, 2021 30 minutes ago, Attila Kovacs said: Am I the only one annoyed that these are in System.Math? Without unit math use a custom one and you are not annoyed anymore 🙂 function myMin(const ValueA, ValueB: Integer): Integer; begin if (ValueA <= ValueB) then Result := ValueA else Result := ValueB; end; function myMax(const ValueA, ValueB: Integer): Integer; begin if (ValueA >= ValueB) then Result := ValueA else Result := ValueB; end; Share this post Link to post
Guest Posted March 23, 2021 1 hour ago, Attila Kovacs said: Am I the only one annoyed that these are in System.Math? I'm with you 🙂 After a lot of times it's more like; "ah, that again". Share this post Link to post
David Heffernan 2345 Posted March 23, 2021 Why does this bother you? Why don't you want to use System.Math? Share this post Link to post
Guest Posted March 23, 2021 (edited) It's simply because of being very very lazy. Oops, sorry not my OP. Edited March 23, 2021 by Guest Share this post Link to post
Attila Kovacs 629 Posted March 23, 2021 35 minutes ago, Dany Marmur said: "ah, that again". _exactly_ 32 minutes ago, David Heffernan said: Why don't you want to use System.Math? Because if someone sees it, he could think I can do math 🙂 1 Share this post Link to post
Fr0sT.Brutal 900 Posted March 23, 2021 Me too! Implemented my own routines for this Share this post Link to post
Guest Posted March 23, 2021 you have to complain about life because you need to breathe! will understand such brilliant minds! hug Share this post Link to post
Clément 148 Posted March 23, 2021 (edited) deleted Edited March 23, 2021 by Clément Share this post Link to post
Stefan Glienke 2002 Posted March 23, 2021 I am more annoyed with the unnecessary conditional jumps they generate and the fact they don't inline when using runtime packages 1 Share this post Link to post
Guest Posted March 23, 2021 Yes, "functionalizing" these thingies needs all expressions to have to be evaluate-able. So one still have to "fence" the minMaxIfThen(...). Makes it kind of a blow in the air. Share this post Link to post
Vandrovnik 214 Posted March 23, 2021 30 minutes ago, Stefan Glienke said: I am more annoyed with the unnecessary conditional jumps they generate and the fact they don't inline when using runtime packages Is it possible to implement Min or Max without conditional jump? Share this post Link to post
Stefan Glienke 2002 Posted March 23, 2021 (edited) 37 minutes ago, Vandrovnik said: Is it possible to implement Min or Max without conditional jump? Not that I know of because the compiler unfortunately does not utilize the cmovxx instruction. This has been reported already (I think there are other reports similar to this one): https://quality.embarcadero.com/browse/RSP-21955 Edit: Here is what clang and gcc generate: https://godbolt.org/z/4hnYrjYM6 And this is what Delphi generates: Project1.dpr.16: Result := min(i, 42); 00408F94 83F82A cmp eax,$2a 00408F97 7E05 jle $00408f9e 00408F99 B82A000000 mov eax,$0000002a Project1.dpr.17: end; 00408F9E C3 ret Project1.dpr.16: Result := min(i, 42); 000000000040D4F0 83F92A cmp ecx,$2a 000000000040D4F3 7F04 jnle Main + $9 000000000040D4F5 89C8 mov eax,ecx 000000000040D4F7 EB05 jmp Main + $E 000000000040D4F9 B82A000000 mov eax,$0000002a Project1.dpr.17: end; 000000000040D4FE C3 ret Yeah yeah branch predictors and all that - but if they are filled up with garbage conditional jumps like this they have less room for the important ones. Edited March 23, 2021 by Stefan Glienke 3 Share this post Link to post
Vandrovnik 214 Posted March 23, 2021 19 minutes ago, Stefan Glienke said: Not that I know of because the compiler unfortunately does not utilize the cmovxx instruction. This has been reported already (I think there are other reports similar to this one): https://quality.embarcadero.com/browse/RSP-21955 Thanks, voted... My knowledge of assembler is frozen before Pentium instruction set... Share this post Link to post
Vincent Parrett 750 Posted March 23, 2021 1 hour ago, Stefan Glienke said: This has been reported already (I think there are other reports similar to this one): https://quality.embarcadero.com/browse/RSP-21955 Edit: Here is what clang and gcc generate: https://godbolt.org/z/4hnYrjYM6 And this is what Delphi generates: Gotta support all those 386's that are still floating around 🙄 voted. Share this post Link to post
Vandrovnik 214 Posted March 23, 2021 I have also found this comparing of the performance: https://github.com/xiadz/cmov 2 Share this post Link to post
Attila Kovacs 629 Posted March 23, 2021 @Vandrovnik Brutal. Voted too. But I don't think they touch the compiler in the near future, however, I've noticed that reports regarding to the IDE are opened in a couple of workdays at the time and also being fixed. I'm surprisingly satisfied with that. 1 Share this post Link to post
mvanrijnen 123 Posted March 24, 2021 13 hours ago, Dany Marmur said: Yes, "functionalizing" these thingies needs all expressions to have to be evaluate-able. So one still have to "fence" the minMaxIfThen(...). Makes it kind of a blow in the air. i have a minmax and maxmin function 🙂 Share this post Link to post
Guest Posted March 24, 2021 7 hours ago, mvanrijnen said: i have a minmax and maxmin function 🙂 Can you do this using your function? var lSomeObject: TObject; begin Result := MyInlineIfFunction(FValue, CConst, lSomeObject.Value); end; Assuming FValue is true, will you get the result of CConst or an AV/GPF? Share this post Link to post