trying to simplify an algorithm

Johan V. johan at localhost.localdomain
Mon Feb 28 18:59:32 PST 2005


Ian Molton wrote:

> Johan V. wrote:
> 
>> I know it's very obscured. Think about the wasted clock cycles for a
>> minute, the above can be implemented without conditional jumps ...
> 
> More to the point though I think technically its broken. Im fairly sure
> C only defines 0 to be false. *all* other values are true, therefore you
> are relying on the compiler to use 1.
> 
> also from an assembler standpoint, some CPUs may not be able to
> implement reg = (a>0) without a branch.
> 
> best to use conditionals and let the compiler work out how best to fit
> them around the target CPU. (even better to go fix gcc so it does that
> well)

It was the worst possible code I could come up with. So every critisism it
gets is justified :)



More information about the lfs-chat mailing list