[Ffmpeg-devel] GCC optimizations

Guillaume POIRIER poirierg
Sun May 28 23:40:25 CEST 2006


On 5/28/06, Justin Ruggles <jruggle at earthlink.net> wrote:
> Guillaume POIRIER wrote:
> > On 5/28/06, Justin Ruggles <jruggle at earthlink.net> wrote:

> >>While working on the FLAC encoder, I have come across a problem I've
> >>never encountered.  I am getting completely different results using gcc
> >>with optimization vs. without optimization.  Using -O0 gives me good
> >>results, but using -O1 to -O3 gives bad (but still valid) results.
> >
> >
> > You mean that the performance of you code decrease as you increase the
> > optimization level? This seems odd. -O1, -O2, -Os should always be
> > better than -O0 (which is pretty much like macro-expand).
> >
> Actually, it's not the performance that's the issue.  I get different
> output from the encoder.  File sizes and contents are different.

I imagine that it's quite possible. The C norm is very complex,
therefore when you get into some corner cases, you can have the
compiler do what you meant with -O0 and do what you wrote with
-O1/2/3. So I'd say the bug _may_ be in your code.

The best way to find out is obviously to test with other versions of
gcc, and/or compile each file with/without optimizations and test...

"Success consists of going from failure to failure without loss of enthusiasm."
 -- Winston Churchill

More information about the ffmpeg-devel mailing list