From owner-freebsd-hackers@FreeBSD.ORG Mon Jan 31 03:53:13 2005 Return-Path: Delivered-To: freebsd-hackers@freebsd.org Received: from mx1.FreeBSD.org (mx1.freebsd.org [216.136.204.125]) by hub.freebsd.org (Postfix) with ESMTP id 1C5AC16A4CE for ; Mon, 31 Jan 2005 03:53:13 +0000 (GMT) Received: from VARK.MIT.EDU (VARK.MIT.EDU [18.95.3.179]) by mx1.FreeBSD.org (Postfix) with ESMTP id B770743D3F for ; Mon, 31 Jan 2005 03:53:12 +0000 (GMT) (envelope-from das@FreeBSD.ORG) Received: from VARK.MIT.EDU (localhost [127.0.0.1]) by VARK.MIT.EDU (8.13.1/8.13.1) with ESMTP id j0V3rNlJ008179; Sun, 30 Jan 2005 22:53:23 -0500 (EST) (envelope-from das@FreeBSD.ORG) Received: (from das@localhost) by VARK.MIT.EDU (8.13.1/8.13.1/Submit) id j0V3rM8R008178; Sun, 30 Jan 2005 22:53:22 -0500 (EST) (envelope-from das@FreeBSD.ORG) Date: Sun, 30 Jan 2005 22:53:22 -0500 From: David Schultz To: "Dag-Erling =?us-ascii:iso-8859-1?Q?Sm=F8rgrav?=" Message-ID: <20050131035322.GA8082@VARK.MIT.EDU> Mail-Followup-To: "Dag-Erling =?us-ascii:iso-8859-1?Q?Sm=F8rgrav?=" , Jacques Fourie , freebsd-hackers@FreeBSD.ORG References: <41F90140.3020705@trispen.com> <20050127160914.GA72454@VARK.MIT.EDU> Mime-Version: 1.0 Content-Type: text/plain; charset="us-ascii:iso-8859-1" Content-Disposition: inline Content-Transfer-Encoding: 8bit In-Reply-To: cc: freebsd-hackers@FreeBSD.ORG Subject: Re: kernel vm question X-BeenThere: freebsd-hackers@freebsd.org X-Mailman-Version: 2.1.1 Precedence: list List-Id: Technical Discussions relating to FreeBSD List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 31 Jan 2005 03:53:13 -0000 On Fri, Jan 28, 2005, Dag-Erling Smrgrav wrote: > des@des.no (Dag-Erling Smørgrav) writes: > > David Schultz writes: > > > When the line is there, the compiler is probably smart enough to > > > realize that 'x=y; y=x' is (usually) a no-op, so it optimizes away > > > both statements. > > Wrong. The compiler is free to optimize away the second statement > > provided that neither x nor y is declared volatile, but it cannot > > optimize away the first statement. > > I should add: unless it can determine with absolute certainty that x > is not referenced later. Exactly. Notice that this is indeed the case for Jaques' example. I oversimplified a bit because, as I mentioned, this is a digression from the main point about writing to the code segment. There's no need to be curt.