From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 13628 invoked by alias); 21 Feb 2014 15:02:53 -0000 Mailing-List: contact gcc-help-help@gcc.gnu.org; run by ezmlm Precedence: bulk List-Id: List-Archive: List-Post: List-Help: Sender: gcc-help-owner@gcc.gnu.org Received: (qmail 13618 invoked by uid 89); 21 Feb 2014 15:02:53 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-4.6 required=5.0 tests=AWL,BAYES_00,RP_MATCHES_RCVD,SPF_HELO_PASS,SPF_PASS autolearn=ham version=3.3.2 X-HELO: mx1.redhat.com Received: from mx1.redhat.com (HELO mx1.redhat.com) (209.132.183.28) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with ESMTP; Fri, 21 Feb 2014 15:02:52 +0000 Received: from int-mx10.intmail.prod.int.phx2.redhat.com (int-mx10.intmail.prod.int.phx2.redhat.com [10.5.11.23]) by mx1.redhat.com (8.14.4/8.14.4) with ESMTP id s1LF2pID008158 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=OK); Fri, 21 Feb 2014 10:02:51 -0500 Received: from zebedee.pink (ovpn-113-90.phx2.redhat.com [10.3.113.90]) by int-mx10.intmail.prod.int.phx2.redhat.com (8.14.4/8.14.4) with ESMTP id s1LF2nio015132; Fri, 21 Feb 2014 10:02:50 -0500 Message-ID: <53076A99.1020709@redhat.com> Date: Fri, 21 Feb 2014 15:02:00 -0000 From: Andrew Haley User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:24.0) Gecko/20100101 Thunderbird/24.3.0 MIME-Version: 1.0 To: Cody Rigney CC: gcc-help@gcc.gnu.org Subject: Re: Compiler optimizing variables in inline assembly References: <5305C77D.3090807@redhat.com> <5307221E.8070409@redhat.com> In-Reply-To: Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: 7bit X-IsSubscribed: yes X-SW-Source: 2014-02/txt/msg00138.txt.bz2 On 02/21/2014 02:06 PM, Cody Rigney wrote: > On Fri, Feb 21, 2014 at 4:53 AM, Andrew Haley wrote: >> >> You can use a memory operand as an output, as in "=m"(*a) or simply >> add "memory" to the clobber list. And you must add all clobbered >> registers to the clobber list. Then it should work. >> > I added all the registers and "memory" to clobber and it worked! > Since I think it's more efficient to specify which memory is changing, > I'm going to give the "=m" (*a) a shot. So even though you > dereference the pointer, gcc will know the length of the memory(say 2 > bytes) that changes? Or do you have to specify each index of the > memory(e.g. char a[2]; ..... asm ... "=m" (*a), "=m" (*(a+1)))? It's hard for me to give a 100% answer to that one, but GCC has an idea what memory is reachable from every pointer. So, this won't clobber memory that's unreachable or has a different type from that pointer. It probably doesn't matter. Andrew. P.S. Please don't top-post on GCC lists. :-)