[fpc-devel] Bit manipulation as optimization in FPC
Florian Klaempfl
florian at freepascal.org
Wed Sep 6 22:00:51 CEST 2006
Daniël Mantione schrieb:
>
> Op Wed, 6 Sep 2006, schreef ik:
>
>> 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.
It does, if the reg. allocator starts correctly :)
>
> Daniël
>
>
> ------------------------------------------------------------------------
>
> _______________________________________________
> fpc-devel maillist - fpc-devel at lists.freepascal.org
> http://lists.freepascal.org/mailman/listinfo/fpc-devel
More information about the fpc-devel
mailing list