public inbox for gcc-bugs@sourceware.org help / color / mirror / Atom feed
From: "marxin at gcc dot gnu.org" <gcc-bugzilla@gcc.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 [thread overview] Message-ID: <bug-108941-4@http.gcc.gnu.org/bugzilla/> (raw) https://gcc.gnu.org/bugzilla/show_bug.cgi?id=108941 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 <jbeulich@suse.com> 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 = 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 = s->priv_data; AVCodecParameters *par = s->streams[0]->codecpar; return adts_decode_extradata(s, adts, par->extradata, par->extradata_size); } static const AVOption options[] = { }; AVOutputFormat ff_adts_muxer = { .init = 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))
next reply other threads:[~2023-02-27 9:39 UTC|newest] Thread overview: 18+ messages / expand[flat|nested] mbox.gz Atom feed top 2023-02-27 9:39 marxin at gcc dot gnu.org [this message] 2023-02-27 9:51 ` [Bug c/108941] " jakub at gcc dot gnu.org 2023-02-27 10:00 ` marxin at gcc dot gnu.org 2023-02-27 10:07 ` jakub at gcc dot gnu.org 2023-02-27 10:17 ` jbeulich at suse dot com 2023-02-27 10:33 ` jakub at gcc dot gnu.org 2023-02-27 10:57 ` jbeulich at suse dot com 2023-02-27 11:00 ` jbeulich at suse dot com 2023-02-27 11:02 ` jakub at gcc dot gnu.org 2023-02-27 11:11 ` jbeulich at suse dot com 2023-02-27 11:14 ` jakub at gcc dot gnu.org 2023-02-27 11:17 ` jakub at gcc dot gnu.org 2023-02-27 11:17 ` marxin at gcc dot gnu.org 2023-02-27 11:23 ` jakub at gcc dot gnu.org 2023-02-28 7:33 ` jbeulich at suse dot com 2023-02-28 7:47 ` jakub at gcc dot gnu.org 2023-02-28 7:59 ` jbeulich at suse dot com 2023-02-28 8:10 ` jakub at gcc dot gnu.org
Reply instructions: You may reply publicly to this message via plain-text email using any one of the following methods: * Save the following mbox file, import it into your mail client, and reply-to-all from there: mbox Avoid top-posting and favor interleaved quoting: https://en.wikipedia.org/wiki/Posting_style#Interleaved_style * Reply using the --to, --cc, and --in-reply-to switches of git-send-email(1): git send-email \ --in-reply-to=bug-108941-4@http.gcc.gnu.org/bugzilla/ \ --to=gcc-bugzilla@gcc.gnu.org \ --cc=gcc-bugs@gcc.gnu.org \ /path/to/YOUR_REPLY https://kernel.org/pub/software/scm/git/docs/git-send-email.html * If your mail client supports setting the In-Reply-To header via mailto: links, try the mailto: linkBe sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions for how to clone and mirror all data and code used for this inbox; as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).