public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
From: "trippels at gcc dot gnu.org" <gcc-bugzilla@gcc.gnu.org>
To: gcc-bugs@gcc.gnu.org
Subject: [Bug tree-optimization/60902] [4.9/4.10 Regression] ffmpeg built with gcc 4.9 RC produces incorrect flac playback code
Date: Mon, 21 Apr 2014 07:34:00 -0000	[thread overview]
Message-ID: <bug-60902-4-4NMR9fDUPi@http.gcc.gnu.org/bugzilla/> (raw)
In-Reply-To: <bug-60902-4@http.gcc.gnu.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.


  parent reply	other threads:[~2014-04-21  7:34 UTC|newest]

Thread overview: 35+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2014-04-20  8:45 [Bug c/60902] New: " arthur.marsh at internode dot on.net
2014-04-20  8:48 ` [Bug target/60902] " pinskia at gcc dot gnu.org
2014-04-20  9:34 ` arthur.marsh at internode dot on.net
2014-04-20  9:39 ` arthur.marsh at internode dot on.net
2014-04-20  9:42 ` arthur.marsh at internode dot on.net
2014-04-20  9:43 ` pinskia at gcc dot gnu.org
2014-04-20  9:46 ` mpolacek at gcc dot gnu.org
2014-04-20 10:23 ` arthur.marsh at internode dot on.net
2014-04-20 10:24 ` arthur.marsh at internode dot on.net
2014-04-20 10:34 ` trippels at gcc dot gnu.org
2014-04-20 11:53 ` trippels at gcc dot gnu.org
2014-04-20 12:18 ` trippels at gcc dot gnu.org
2014-04-20 13:20 ` trippels at gcc dot gnu.org
2014-04-20 13:31 ` [Bug tree-optimization/60902] " trippels at gcc dot gnu.org
2014-04-20 13:31 ` trippels at gcc dot gnu.org
2014-04-20 17:19 ` [Bug tree-optimization/60902] [4.9/4.10 Regression] " trippels at gcc dot gnu.org
2014-04-20 17:22 ` trippels at gcc dot gnu.org
2014-04-20 17:29 ` trippels at gcc dot gnu.org
2014-04-20 17:32 ` trippels at gcc dot gnu.org
2014-04-21  7:34 ` trippels at gcc dot gnu.org [this message]
2014-04-22  5:10 ` law at redhat dot com
2014-04-22  6:42 ` law at redhat dot com
2014-04-22  7:21 ` law at redhat dot com
2014-04-22  7:29 ` law at redhat dot com
2014-04-22  8:50 ` rguenth at gcc dot gnu.org
2014-04-23  5:15 ` law at redhat dot com
2014-04-23  7:04 ` trippels at gcc dot gnu.org
2014-04-23  9:17 ` trippels at gcc dot gnu.org
2014-04-23  9:44 ` trippels at gcc dot gnu.org
2014-04-23 18:05 ` law at gcc dot gnu.org
2014-04-25 19:22 ` [Bug tree-optimization/60902] [4.9 " jamrial at gmail dot com
2014-04-25 19:51 ` law at redhat dot com
2014-04-28 13:38 ` law at gcc dot gnu.org
2014-05-13 20:27 ` law at gcc dot gnu.org
2014-05-13 20:28 ` law at redhat dot com

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=bug-60902-4-4NMR9fDUPi@http.gcc.gnu.org/bugzilla/ \
    --to=gcc-bugzilla@gcc.gnu.org \
    --cc=gcc-bugs@gcc.gnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).