Op Wed, 6 Sep 2006, schreef ik:
Show quoted text 18 lines
Hello,
I wonder if FPC optimize a code such as:
if a < b then
c := d
else
c := b;
as :
r := b + ((d - b) and -(a < b));
If so, do you check the type of CPU (because as I understand, some CPU
will not execute as fast as other CPU's.
If not, then why, and how would you optimize such code ?
The construction above would be fastest with conditional moves; in the above construction the optimal code generation would be:
mov c,d
cmp a,b
movge c,b
This would be much faster than any code generated for the construction you propose.
Free Pascal won't generate the optimal code, but it can already use conditional moves and I would expect that the compiler would use it in this situation.
Daniël