From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 5015 invoked by alias); 19 Nov 2012 04:37:05 -0000 Received: (qmail 3464 invoked by uid 48); 19 Nov 2012 04:36:38 -0000 From: "pinskia at gcc dot 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 X-Bugzilla-Reason: CC X-Bugzilla-Type: changed X-Bugzilla-Watch-Reason: None X-Bugzilla-Product: gcc X-Bugzilla-Component: target X-Bugzilla-Keywords: X-Bugzilla-Severity: normal X-Bugzilla-Who: pinskia at gcc dot gnu.org X-Bugzilla-Status: RESOLVED X-Bugzilla-Priority: P3 X-Bugzilla-Assigned-To: unassigned at gcc dot gnu.org X-Bugzilla-Target-Milestone: --- X-Bugzilla-Changed-Fields: Status Resolution Message-ID: In-Reply-To: References: X-Bugzilla-URL: http://gcc.gnu.org/bugzilla/ Auto-Submitted: auto-generated Content-Type: text/plain; charset="UTF-8" MIME-Version: 1.0 Mailing-List: contact gcc-bugs-help@gcc.gnu.org; run by ezmlm Precedence: bulk List-Id: List-Archive: List-Post: List-Help: Sender: gcc-bugs-owner@gcc.gnu.org X-SW-Source: 2012-11/txt/msg01704.txt.bz2 http://gcc.gnu.org/bugzilla/show_bug.cgi?id=55377 Andrew Pinski changed: What |Removed |Added ---------------------------------------------------------------------------- Status|UNCONFIRMED |RESOLVED Resolution| |INVALID --- Comment #1 from Andrew Pinski 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.