From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 48) id BF8843858D39; Tue, 28 Feb 2023 07:47:36 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org BF8843858D39 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gcc.gnu.org; s=default; t=1677570456; bh=VxMBmEAe3wRsWSvd01JDzWJdcT2pKFipin4aun68RfA=; h=From:To:Subject:Date:In-Reply-To:References:From; b=sIL0dfYxD4+U0/74vD97XBTQL9ulEE7mUC6OWzYNCBzK+NQAT2B/n/GaJCL2vjDPV FbcWI9deDT8WSa6y8HzEd832fm8eOKbOV+lRi4477cvFw/fywJVLkNb7PN2GE7Njkg N4OA1zcxSgOdkBCVs2t8TopP+Cd4nh/w9yCDTMzM= From: "jakub at gcc dot gnu.org" To: gcc-bugs@gcc.gnu.org Subject: [Bug c/108941] Error: operand type mismatch for `shr' with binutils master Date: Tue, 28 Feb 2023 07:47:36 +0000 X-Bugzilla-Reason: CC X-Bugzilla-Type: changed X-Bugzilla-Watch-Reason: None X-Bugzilla-Product: gcc X-Bugzilla-Component: c X-Bugzilla-Version: 13.0 X-Bugzilla-Keywords: X-Bugzilla-Severity: normal X-Bugzilla-Who: jakub at gcc dot gnu.org X-Bugzilla-Status: RESOLVED X-Bugzilla-Resolution: INVALID X-Bugzilla-Priority: P3 X-Bugzilla-Assigned-To: unassigned at gcc dot gnu.org X-Bugzilla-Target-Milestone: --- X-Bugzilla-Flags: X-Bugzilla-Changed-Fields: Message-ID: In-Reply-To: References: Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable X-Bugzilla-URL: http://gcc.gnu.org/bugzilla/ Auto-Submitted: auto-generated MIME-Version: 1.0 List-Id: https://gcc.gnu.org/bugzilla/show_bug.cgi?id=3D108941 --- Comment #15 from Jakub Jelinek --- (In reply to jbeulich from comment #14) > (In reply to Jakub Jelinek from comment #5) > > GCC doesn't even have that information at all, at the RTL level it does= n't > > know > > if it was signed or unsigned. > > All it has is the constraint and operand for it, like (reg:QI 126) or > > (const_int -1). >=20 > Lack of information at a certain layer doesn't mean this isn't a bug. It > merely makes whatever possible bug one that's hard to fix. Well, we are talking about behavior of an extension that behaved since its introduction that way and lots of code in the wild can rely on that behavio= r. So, why would you all of sudden consider it a bug? > Furthermore you did refer to gcc internal doc as to justifying the behavi= or. > But can you also point me at non-internal doc making explicit that e.g. >=20 > static inline unsigned aux(unsigned i, unsigned char j) { > #if 1 > asm("add %1,%0" : "+rm" (i) : "i" (j)); This is just misunderstanding on how inline asm works. GCC (intentionally) treats inline asm as a black box, text in which it does replacements according to = the rules, it is a very low level interface and needs the author know what they are do= ing. Above you're mixing a 32-bit argument with 8-bit argument in an instruction which expects probably 2 32-bit arguments or at least both arguments with the same width. Just try to pass 2 variables to it and use "ri" and you'll see assembler errors, add %dl, %eax and the like. There are various modifiers (often target specific) which allows one to say a particular operand should be printed as if in this mode, when you don't use them, it means the operand mode is to be used. So, for add above one should really use "i" ((int) j) if you want it 32-bit. Similarly how ffmpeg should be using "rI" instead of "ri" that it uses... 'I' Integer constant in the range 0 ... 31, for 32-bit shifts. even documents it that way.=