using !
Dave Gillett
dgil at pa.reuter.COM
Fri Dec 28 13:50:24 AEST 1990
In <544 at taumet.com> steve at taumet.com (Stephen Clamage) writes:
>heroux at cemmva.cem.msu.edu (Brett Heroux) writes:
>>Is !(a > b) portable?
>>slower or faster than a <= b?
>Depends on the compiler and machine. Many compilers will generate
>identical code for both constructs. You can look at the code your
>compiler generates for each construct, and if they are different,
>measure the time taken by each version. If you choose one construct
>on this basis, you must realize that the next compiler or machine you
>use may not produce the same result.
If you find a compiler that generates different code for the two cases,
it is most likely to have crudely generated code for the !(a > b) case, where
two different operators appear, rather than for the single operator in the
a <= b case. So while a good compiler will generate the same code for both
cases, a bad compiler is likely to generate better code for the a <= b case.
Dave
More information about the Comp.lang.c
mailing list