Jump to content

Recommended Posts

Guest

Perhaps, since you must have been born with this "gift" :)))   :classic_cheerleader: :classic_biggrin:

 

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

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.

  • Like 1
  • Haha 1

Share this post


Link to post
Guest

thanks for watch me! :classic_ninja:

 

hug

Share this post


Link to post
Guest

did know that the "structures" seems dont have changed until today?

  • same "DATA array"
  • same > and < use

 

hug

Share this post


Link to post
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
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
Guest

It's simply because of being very very lazy.

Oops, sorry not my OP.

Edited by Guest

Share this post


Link to post
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 🙂

  • Haha 1

Share this post


Link to post
Guest

you have to complain about life because you need to breathe!

will understand such brilliant minds! :classic_cool:

 

hug

Share this post


Link to post

I am more annoyed with the unnecessary conditional jumps they generate and the fact they don't inline when using runtime packages

  • Like 1

Share this post


Link to post
Guest

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
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
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 by Stefan Glienke
  • Like 3

Share this post


Link to post
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
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 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.

  • Like 1

Share this post


Link to post
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
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

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

×