public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
From: "pinskia at gcc dot gnu.org" <gcc-bugzilla@gcc.gnu.org>
To: gcc-bugs@gcc.gnu.org
Subject: [Bug target/55377] ipa-pure-cont produces wrong code on AVR
Date: Mon, 19 Nov 2012 04:37:00 -0000	[thread overview]
Message-ID: <bug-55377-4-oxcc41uzTK@http.gcc.gnu.org/bugzilla/> (raw)
In-Reply-To: <bug-55377-4@http.gcc.gnu.org/bugzilla/>


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=55377

Andrew Pinski <pinskia at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|UNCONFIRMED                 |RESOLVED
         Resolution|                            |INVALID

--- Comment #1 from Andrew Pinski <pinskia at gcc dot gnu.org> 2012-11-19 04:36:36 UTC ---
This looks correct as the only thing as:
  while (!serial.canWrite()) {}

cannot change its state once in that loop as far as I can tell.  There are no
volatile variables read either.

canWrite is inlined which was:
 bool canWrite() {
  return !(_txPointers.full(sizeof(TXBuffer)));
 }

And we decided mhvlib::RingBuffer::full only reads from its arguments which are
not volatile.

full does:
 bool full(uint8_t blockLength) {
  return length() > (_size - 1 - blockLength);
 }

Where length was:

 uint8_t length() {
  int16_t length = _head - _tail;
  if (length < 0) {

   length = (_size - _tail) + _head + 1;
  }

  return (uint8_t) length;
 }

And both _head and _tail are not marked as volatile so we only need to read
them once (including through the loop).

So the code that ipa-pure-const is producing is correct.
The reason why you can't produce a simpler testcase is because it depends on
other optimization chooses that the compiler has decided to take.  

So in conclusion, I think you are missing some variables marked as volatile in
the RingBuffer implementation and/or Device_TXImplementation implementation.


      reply	other threads:[~2012-11-19  4:37 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2012-11-18 12:41 [Bug c++/55377] New: " gcc@d-silva.org
2012-11-19  4:37 ` pinskia at gcc dot gnu.org [this message]

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-55377-4-oxcc41uzTK@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).