From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 48) id 4DE6D3858D35; Mon, 27 Feb 2023 09:39:24 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 4DE6D3858D35 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gcc.gnu.org; s=default; t=1677490764; bh=1e3yN6i408dU43gqt7YMZPW47TtfpCGTBZwyO7ZsW5s=; h=From:To:Subject:Date:From; b=vZxPgdraTQ+xpcK9Ba1xbmifOXoRJqmEgAaiq3Dr9THAhVwKurLts7NT9772RglE2 r1jo9Td5jreh2p0YyQdiLbbvvsQ0RMisWd+Kt+8P7SHFGIv1yIbnVuHbkCuYW4NMQV 6/9pQh06eRT8S52OUcdHAvxEO/0+dNqBbW2mA4KI= From: "marxin at gcc dot gnu.org" To: gcc-bugs@gcc.gnu.org Subject: [Bug c/108941] New: Error: operand type mismatch for `shr' with binutils master Date: Mon, 27 Feb 2023 09:39:17 +0000 X-Bugzilla-Reason: CC X-Bugzilla-Type: new 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: marxin at gcc dot gnu.org X-Bugzilla-Status: UNCONFIRMED X-Bugzilla-Resolution: 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: bug_id short_desc product version bug_status bug_severity priority component assigned_to reporter cc target_milestone Message-ID: 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 Bug ID: 108941 Summary: Error: operand type mismatch for `shr' with binutils master Product: gcc Version: 13.0 Status: UNCONFIRMED Severity: normal Priority: P3 Component: c Assignee: unassigned at gcc dot gnu.org Reporter: marxin at gcc dot gnu.org CC: jbeulich at suse dot com Target Milestone: --- Since the following binutils revision: commit c34d1cc9200ae24dc7572aaf77d80276c0490e9b Author: Jan Beulich Date: Fri Feb 24 13:56:57 2023 +0100 x86: restrict insn templates accepting negative 8-bit immediates I noticed the following rejected code (reduced from ffmpeg-4 package): $ cat libavformat.i void av_log(); typedef signed char __int8_t; typedef unsigned char __uint8_t; typedef unsigned int __uint32_t; typedef __int8_t int8_t; typedef __uint8_t uint8_t; typedef __uint32_t uint32_t; typedef struct AVCodecParameters { uint8_t *extradata; int extradata_size; } AVCodecParameters; static inline uint32_t NEG_USR32(uint32_t a, int8_t s) { __asm__("shrl %1, %0\n\t" : "+r"(a) : "ic"((uint8_t)(-s))); return a; } typedef struct GetBitContext { } GetBitContext; static inline unsigned int get_bits(GetBitContext *s, int n) { register unsigned int tmp; unsigned int __attribute__((unused)) re_cache; tmp =3D NEG_USR32(re_cache, n); return tmp; }; typedef struct AVOption { } AVOption; typedef struct AVOutputFormat { int (*init)(struct AVFormatContext *); } AVOutputFormat; typedef struct AVStream { AVCodecParameters *codecpar; } AVStream; typedef struct AVProgram { void *priv_data; AVStream **streams; } AVFormatContext; typedef struct ADTSContext { } ADTSContext; static int adts_decode_extradata(AVFormatContext *s, ADTSContext *adts, const uint8_t *buf, int size) { GetBitContext gb; if (get_bits(&gb, 1)) { av_log(s, 16, "Extension flag is not allowed in ADTS\n"); } } static int adts_init(AVFormatContext *s) { ADTSContext *adts =3D s->priv_data; AVCodecParameters *par =3D s->streams[0]->codecpar; return adts_decode_extradata(s, adts, par->extradata, par->extradata_si= ze); } static const AVOption options[] =3D { }; AVOutputFormat ff_adts_muxer =3D { .init =3D adts_init, }; $ gcc libavformat.i -w -S -O2 && grep shr libavformat.s && /home/marxin/Programming/binutils/objdir/gas/as-new libavformat.s shrl $-1, %eax libavformat.i: Assembler messages: libavformat.i:14: Error: operand type mismatch for `shr' So we emit -1 even though the user used cast to uint8_t: ((uint8_t)(-s))=