[FFmpeg-devel] [RFC] abs vs FFABS
Sat Jan 17 17:10:22 CET 2009
On Sat, 2009-01-17 at 10:32 -0500, Ronald S. Bultje wrote:
>  1billion abs/FFABS cycles + some checks, m = macro (FFABS()), b =
> built-in (abs()), see attached code
> i686-apple-darwin8-gcc-4.0.1 (GCC) 4.0.1 (Apple Computer, Inc. build
> 5367), compiled with -O3
That's 3 versions and over 3 years behind current GCC. You should do
tests with a newer compiler.
> static int test_macro(int total)
> if ((res = ABS(start)) < 0)
> return 1;
The compiler should be able to optimize that whole function to
"return 0;", and current GCC does. Your test shows essentially nothing
except an optimization limitation in old GCC. To see whether there is
any real effect on code generation you'd need to write a test where the
compiler can't optimize away the calculation of the exact result.
abs is simple enough that in most cases the compiler can probably handle
the function and the macro the same. If there are no clear difference in
the result, it's better to use the function because it is more standard.
More information about the ffmpeg-devel