https://gcc.gnu.org/bugzilla/show_bug.cgi?id=112816

            Bug ID: 112816
           Summary: internal compiler error: in extract_insn, at
                    recog.cc:2804, unrecognizable_insn for
                    __builtin_signbit
           Product: gcc
           Version: unknown
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: middle-end
          Assignee: unassigned at gcc dot gnu.org
          Reporter: a.elovikov at gmail dot com
  Target Milestone: ---

https://godbolt.org/z/3vzejjWcq

constexpr int N = 4;

template <typename T>
struct S {
    T x[N];
    T& operator[](int idx) { return x[idx]; }
};
auto foo(S<float> x) {
  S<int> res;
  for (int i = 0; i < 4; ++i)
    res[i] = __builtin_signbit(x[i]) ? -1 : 0;
  return res;
}

Copy-pasting "x86-64 gcc (trunk)" output from the godbolt link above (-O3
-std=c++17 options used):
<source>: In function 'auto foo(S<float>)':
<source>:13:1: error: unrecognizable insn:
   13 | }
      | ^
(insn 20 19 21 2 (set (reg:V4SI 99 [ vect__2.11 ])
        (lshiftrt:V4SI (subreg:V4SI (subreg:V4SF (reg/v:TI 105 [ x ]) 0) 0)
            (const_int 31 [0x1f]))) "<source>":11:31 discrim 1 -1
     (nil))
during RTL pass: vregs
<source>:13:1: internal compiler error: in extract_insn, at recog.cc:2804
0x26c14fe internal_error(char const*, ...)
        ???:0
0xb125b9 fancy_abort(char const*, int, char const*)
        ???:0
0x925e6a _fatal_insn(char const*, rtx_def const*, char const*, int, char
const*)
        ???:0
0x925e8c _fatal_insn_not_found(rtx_def const*, char const*, int, char const*)
        ???:0
Please submit a full bug report, with preprocessed source (by using
-freport-bug).
Please include the complete backtrace with any bug report.
See <https://gcc.gnu.org/bugs/> for instructions.
Compiler returned: 1

Also reproducible with (the version I discovered it with)

$ g++ --version
g++ (Ubuntu 11.4.0-1ubuntu1~22.04) 11.4.0
Copyright (C) 2021 Free Software Foundation, Inc.
This is free software; see the source for copying conditions.  There is NO
warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.

Reply via email to