This is the mail archive of the
gcc-bugs@gcc.gnu.org
mailing list for the GCC project.
[Bug tree-optimization/60902] [4.9/4.10 Regression] ffmpeg built with gcc 4.9 RC produces incorrect flac playback code
- From: "trippels at gcc dot gnu.org" <gcc-bugzilla at gcc dot gnu dot org>
- To: gcc-bugs at gcc dot gnu dot org
- Date: Mon, 21 Apr 2014 07:34:31 +0000
- Subject: [Bug tree-optimization/60902] [4.9/4.10 Regression] ffmpeg built with gcc 4.9 RC produces incorrect flac playback code
- Auto-submitted: auto-generated
- References: <bug-60902-4 at http dot gcc dot gnu dot org/bugzilla/>
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=60902
--- Comment #20 from Markus Trippelsdorf <trippels at gcc dot gnu.org> ---
All three testcases use the same inline function libavcodec/golomb.h:
314 /**
315 * read unsigned golomb rice code (jpegls).
316 */
317 static inline int get_ur_golomb_jpegls(GetBitContext *gb, int k, int limit,
318 int esc_len)
319 {
320 unsigned int buf;
321 int log;
322
323 OPEN_READER(re, gb);
324 UPDATE_CACHE(re, gb);
325 buf = GET_CACHE(re, gb);
326
327 log = av_log2(buf);
328
329 if (log - k >= 32 - MIN_CACHE_BITS + (MIN_CACHE_BITS == 32) &&
330 32 - log < limit) {
331 buf >>= log - k;
332 buf += (30 - log) << k;
333 LAST_SKIP_BITS(re, gb, 32 + k - log);
334 CLOSE_READER(re, gb);
335
336 return buf;
337 } else {
338 int i;
339 for (i = 0; i < limit && SHOW_UBITS(re, gb, 1) == 0; i++) {
340 if (gb->size_in_bits <= re_index)
341 return -1;
342 LAST_SKIP_BITS(re, gb, 1);
343 UPDATE_CACHE(re, gb);
344 }
345 SKIP_BITS(re, gb, 1);
346
347 if (i < limit - 1) {
348 if (k) {
349 buf = SHOW_UBITS(re, gb, k);
350 LAST_SKIP_BITS(re, gb, k);
351 } else {
352 buf = 0;
353 }
354
355 CLOSE_READER(re, gb);
356 return buf + (i << k);
357 } else if (i == limit - 1) {
358 buf = SHOW_UBITS(re, gb, esc_len);
359 LAST_SKIP_BITS(re, gb, esc_len);
360 CLOSE_READER(re, gb);
361
362 return buf + 1;
363 } else
364 return -1;
365 }
366 }
And indeed adding __attribute__ ((optimize(0))) to it "fixes" all three
testcases.
The function looks suspicious and I'm not sure if the code is valid.