From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 26248 invoked by alias); 22 Jun 2010 15:17:42 -0000 Received: (qmail 26237 invoked by uid 22791); 22 Jun 2010 15:17:41 -0000 X-SWARE-Spam-Status: No, hits=-1.9 required=5.0 tests=AWL,BAYES_00,T_RP_MATCHES_RCVD X-Spam-Check-By: sourceware.org Received: from mail.codesourcery.com (HELO mail.codesourcery.com) (38.113.113.100) by sourceware.org (qpsmtpd/0.43rc1) with ESMTP; Tue, 22 Jun 2010 15:17:35 +0000 Received: (qmail 20578 invoked from network); 22 Jun 2010 15:17:33 -0000 Received: from unknown (HELO ?10.153.6.134?) (mitchell@127.0.0.2) by mail.codesourcery.com with ESMTPA; 22 Jun 2010 15:17:33 -0000 Message-ID: <4C20D40B.30904@codesourcery.com> Date: Tue, 22 Jun 2010 15:37:00 -0000 From: Mark Mitchell User-Agent: Thunderbird 2.0.0.24 (Windows/20100228) MIME-Version: 1.0 To: Michael Matz CC: Richard Guenther , Nathan Sidwell , GCC Patches Subject: Re: [gimple] assignments to volatile References: <4C1F5380.1090107@codesourcery.com> In-Reply-To: Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 7bit Mailing-List: contact gcc-patches-help@gcc.gnu.org; run by ezmlm Precedence: bulk List-Id: List-Archive: List-Post: List-Help: Sender: gcc-patches-owner@gcc.gnu.org X-SW-Source: 2010-06/txt/msg02188.txt.bz2 Michael Matz wrote: >>> Sometimes we re-read the assigned-to object, and sometimes we do not. For >>> instance, >>> return vobj = data; >>> will cause a reread of vobj, IF data is not a constant. > > I'd consider the latter condition a bug. I.e. the rereading must happen > in every case. I think that it's without question that: vobj = data; should not cause a read from vobj; the value is not used. I think real-world embedded programmers would be surprised to see a read from an I/O register there. Do you agree? Similarly, I think that: cond ? vobj = data : ... should not cause a read from vobj. The conditional in this case is just a form of if/then; it would surprise programmers if this behaved differently from: if (cond) vobj = data; Do you agree? The case of: x = vobj = data; is different because the value is being used. In that case, I have no strong opinion. Rather than argue about this last case in theory, though, I'd be inclined to look at existing practice. What do RealView, CodeWarrior, Green Hills or other long-standing compilers for embedded systems do? If there's a clear consensus, we can follow that. -- Mark Mitchell CodeSourcery mark@codesourcery.com (650) 331-3385 x713