From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 6678 invoked by alias); 20 Feb 2019 03:10:08 -0000 Mailing-List: contact gcc-help@gcc.gnu.org; run by ezmlm Precedence: bulk List-Id: List-Archive: List-Post: List-Help: Sender: gcc-owner@gcc.gnu.org Received: (qmail 6631 invoked by uid 89); 20 Feb 2019 03:10:08 -0000 Authentication-Results: sourceware.org; auth=none X-Spam-SWARE-Status: No, score=-1.9 required=5.0 tests=BAYES_00,FREEMAIL_FROM,RCVD_IN_DNSWL_NONE,SPF_PASS autolearn=ham version=3.3.2 spammy=31PM, 31pm, HX-Received:b287, Hx-languages-length:1611 X-HELO: mail-pl1-f179.google.com Received: from mail-pl1-f179.google.com (HELO mail-pl1-f179.google.com) (209.85.214.179) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with ESMTP; Wed, 20 Feb 2019 03:10:06 +0000 Received: by mail-pl1-f179.google.com with SMTP id e5so11442299plb.5 for ; Tue, 19 Feb 2019 19:10:06 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=date:from:to:cc:subject:message-id:references:mime-version :content-disposition:in-reply-to:user-agent; bh=TmDSy+CP92swC2MKj2+uV5emSOPzjBwb7+TmXLK/FgY=; b=J0SX5EQ4RfV3yzyi1Ve5z5YRIEzrfTt5W7AsOy84EI5C0JkwTxpqb2zTz2M84UCcPI XPH26K6Gc5mHopcW03lDu86Ehg44Fd3LlSLxFrkgLsZT9n113kT2UJ0h/xqk8u/Z6v/9 G0CgMm4XQLi/5D3TebHY8CWSkvYGeuJncHSFjIesGswrgGs9/qnzF8aKQqysGiMElB24 88mJ4GR57u2ha4TVLBo3LjClR+C7uNTgkBwMXiUHYc76bgdk/RVHG3ld0/nuV2v7qY/Z cGHTRP2ytyEyQlTICO0g9Gw7Ax/n8dV5aQ3dvz28rw5DPxw709zZ8TpYd1wbngmb6yzH imRg== Return-Path: Received: from bubble.grove.modra.org ([58.175.241.133]) by smtp.gmail.com with ESMTPSA id o2sm23778902pgq.29.2019.02.19.19.10.02 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Tue, 19 Feb 2019 19:10:03 -0800 (PST) Received: by bubble.grove.modra.org (Postfix, from userid 1000) id 38E2789700; Wed, 20 Feb 2019 13:39:59 +1030 (ACDT) Date: Wed, 20 Feb 2019 03:10:00 -0000 From: Alan Modra To: Peter Bergner Cc: GCC Subject: Re: Question regarding constraint usage within inline asm Message-ID: <20190220030958.GC16787@bubble.grove.modra.org> References: MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: User-Agent: Mutt/1.9.4 (2018-02-28) X-IsSubscribed: yes X-SW-Source: 2019-02/txt/msg00105.txt.bz2 On Mon, Feb 18, 2019 at 01:13:31PM -0600, Peter Bergner wrote: > I have a question about constraint usage in inline asm when we have > an early clobber output operand. The test case is from PR89313 and > looks like the code below (I'm using "r3" for the reg on ppc, but > you could also use "rax" on x86_64, etc.). > > long input; > long > bug (void) > { > register long output asm ("r3"); > asm ("blah %0, %1, %2" : "=&r" (output) : "r" (input), "0" (input)); > return output; > } > > I know an input operand can have a matching constraint associated with > an early clobber operand, as there seems to be code that explicitly > mentions this scenario. In this case, the user has to manually ensure > that the input operand is not clobbered by the early clobber operand. > In the case that the input operand uses an "r" constraint, we just > ensure that the early clobber operand and the input operand are assigned > different registers. My question is, what about the case above where > we have the same variable being used for two different inputs with > constraints that seem to be incompatible? Without the asm("r3") gcc will provide your "blah" instruction with one register for %0 and %2, and another register for %1. Both registers will be initialised with the value of "input". > Clearly, we cannot assign > a register to the "input" variable that is both the same and different > to the register that is assigned to "output". No, you certainly can do that. I think you have found a bug in lra. -- Alan Modra Australia Development Lab, IBM