[M3devel] FW: optimizing range checks?
hendrik at topoi.pooq.com
hendrik at topoi.pooq.com
Sat Mar 6 07:28:06 CET 2010
On Tue, Mar 02, 2010 at 01:16:03PM +0000, Jay K wrote:
>
> Hey that's pretty clever.
>
> It costs a register, but given:
>
>
>
> if (b >= constantX|| b <= -constantY)
> a = 0;
>
>
>
> The C compiler instead does something like:
>
> if ((b + constantY - 1) > (constantX + constantY - 1))
>
> a = 0;
>
>
>
> This is something the front end could do in many cases.?
>
> Adding a constant to eliminate one of the compares and branches is a win.
>
> If an x86 compiler will give up a register for this, then it is probably a win everywhere.
>
>
>
> Granted, it probably requires silent overflow. Oh well.
It requires unsigned arithmetic; in particular the final compare has to
be unsigned.
-- hendrik
More information about the M3devel
mailing list