[fpc-devel] Bit manipulation as optimization in FPC
peter at freepascal.org
Thu Sep 7 07:52:45 CEST 2006
> I wonder if FPC optimize a code such as:
> if a < b then
> c := d
> 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 ?
This is not a generic optimization that will give real benefits. Your code
also relies on the fact that (a<b) always returns 0 or 1. But this is not
garantueed. A boolean is defined as 0=false and everything else is true.
More information about the fpc-devel