> Fellows,
>
> I am just trying to find a prefferable solution for a compare codes (32
bit
> vars) - test against zero.
> So, analyzing IAR's output, I see, that EQ tests preformed as follows:
>
> mov &var, r12
> and &var+2, r12
> jeq Label
>
> whereas GCC does:
>
> tst &var+2 ; will be issued if necessary, likely not...
> jne +4
> tst &var
> jeq .Label
>
> Which one  _you_ think is better?
>
> ~d
>

Well, the advantage of the gcc version is that it is faster if the high word
is non-zero, but it is slower if the low word also needs to be tested.  I
take it by "will be issued if necessary" is because there is a very good
chance that you already have the flags set because the previous statement
was a calculation on that variable (such as, "if (--n) ..").  In this case,
the gcc code is definitely faster.  However, if you don't have that flag
already, then how about testing &var first, then &var+2 afterwards?  As a
wild assumption, I would guess that it's more likely for a non-zero long to
have a zero hi word than a zero lo word, so more cases will take the
shortcut.

mvh.

David



Reply via email to