From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from gate.crashing.org (gate.crashing.org [63.228.1.57]) by sourceware.org (Postfix) with ESMTP id D83873858CD1 for ; Sun, 7 Jan 2024 18:25:17 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org D83873858CD1 Authentication-Results: sourceware.org; dmarc=none (p=none dis=none) header.from=kernel.crashing.org Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=kernel.crashing.org ARC-Filter: OpenARC Filter v1.0.0 sourceware.org D83873858CD1 Authentication-Results: server2.sourceware.org; arc=none smtp.remote-ip=63.228.1.57 ARC-Seal: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1704651919; cv=none; b=qUxOhS6+70qgCDxGgmSXL9M8Ktqmo1Mnt3EY1OWVB2bMVDqhsqD4VlWeJnB2OSEEo/UWGD3rKJgq/nmRW7uBzhkg7JEOxtiHLaLA5qZsiGMY2gIO7bJFcsuzZSi6VxS5GOd3aH9yvFr20Yeg1CeT/3KP0A7cFCjwc0zcdVeyWAg= ARC-Message-Signature: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1704651919; c=relaxed/simple; bh=zH0caUzARKJgY9LnjNESGPp147FOFhvkIL2ENVeRCAM=; h=Date:From:To:Subject:Message-ID:Mime-Version; b=Y/5ak7mDwdmIesw4jeDjudBuqnD3NwIi0lZhFWqdZx59HmjfkTx948kJzH/WcobWlM3VCvyZgU3gyLp6AsthTqABAaN19+u4lxeE4v9uUDQ60NipaFl5/mAaWHbaDTBCop8xsSsBcZS0GWhUroq8paqdIH4BwsjBS1HJQSSZqWY= ARC-Authentication-Results: i=1; server2.sourceware.org Received: from gate.crashing.org (localhost.localdomain [127.0.0.1]) by gate.crashing.org (8.14.1/8.14.1) with ESMTP id 407IOHF6020281; Sun, 7 Jan 2024 12:24:17 -0600 Received: (from segher@localhost) by gate.crashing.org (8.14.1/8.14.1/Submit) id 407IOGb7020280; Sun, 7 Jan 2024 12:24:16 -0600 X-Authentication-Warning: gate.crashing.org: segher set sender to segher@kernel.crashing.org using -f Date: Sun, 7 Jan 2024 12:24:16 -0600 From: Segher Boessenkool To: David Brown Cc: gcc-help@gcc.gnu.org Subject: Re: Odd error with the "X" inline assembly constraint Message-ID: <20240107182416.GG19790@gate.crashing.org> References: <20240105184612.GE19790@gate.crashing.org> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: User-Agent: Mutt/1.4.2.3i X-Spam-Status: No, score=-2.8 required=5.0 tests=BAYES_00,JMQ_SPF_NEUTRAL,KAM_DMARC_STATUS,SPF_HELO_PASS,SPF_PASS,TXREP,T_SCC_BODY_TEXT_LINE autolearn=no autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on server2.sourceware.org List-Id: On Sun, Jan 07, 2024 at 04:10:21PM +0100, David Brown wrote: > On 05/01/2024 19:46, Segher Boessenkool wrote: > >>However, when I use just "asm ("" : "+X" (x));", I get an error message > >>"error: inconsistent operand constraints in an 'asm'". I have no idea > >>why this is an issue. > > > >The C constraint means "Any operand whatsoever is allowed." Here you > >are saying to use it both as input and as output, and GCC does not know > >how to reload wherever it chose to put it. > > It doesn't need to reload it The error message is emitted during reloading. > >"+" really creates two operands, and ties them together. Writing > > asm("oink" : "+X"(bla)); > >is shorthand for > > asm("oink" : "=X"(bla) : "0"(bla)); > > > > I don't know if these are /exactly/ the same, but they are certainly > similar. They are the same thing. The "+" syntactic sugar is modified during gimplification already, almost nothing in the compiler has to deal with it. See "gimplify_asm_expr", see the code after /* An input/output operand. To give the optimizers more flexibility, split it into separate input and output operands. */ (Constraints that allow registers get a "0" (or "1" etc.) matching constraint for the input duplicate, constraints that do not (like "m") are unmodified. The output duplicate just gets the "+" changed to "="). Segher