public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug c/108941] New: Error: operand type mismatch for `shr' with binutils master
@ 2023-02-27  9:39 marxin at gcc dot gnu.org
  2023-02-27  9:51 ` [Bug c/108941] " jakub at gcc dot gnu.org
                   ` (16 more replies)
  0 siblings, 17 replies; 18+ messages in thread
From: marxin at gcc dot gnu.org @ 2023-02-27  9:39 UTC (permalink / raw)
  To: gcc-bugs

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))

^ permalink raw reply	[flat|nested] 18+ messages in thread

end of thread, other threads:[~2023-02-28  8:10 UTC | newest]

Thread overview: 18+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2023-02-27  9:39 [Bug c/108941] New: Error: operand type mismatch for `shr' with binutils master marxin at gcc dot gnu.org
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

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).