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

            Bug ID: 115982
           Summary: ICE: unrecognizable insn in ira_remove_insn_scratches
                    with -mavx512vl
           Product: gcc
           Version: 15.0
            Status: UNCONFIRMED
          Keywords: ice-on-valid-code
          Severity: normal
          Priority: P3
         Component: rtl-optimization
          Assignee: unassigned at gcc dot gnu.org
          Reporter: pheeck at gcc dot gnu.org
  Target Milestone: ---
              Host: x86_64-linux
            Target: x86_64-linux

Compiling the following code (it comes from llvm testsuite)

```
// RUN: %clang_cc1 -triple %itanium_abi_triple -emit-llvm %s -o - | FileCheck
%s 

typedef __attribute__((__vector_size__(16))) float float4;
typedef __attribute__((__vector_size__(16))) int int4;
typedef __attribute__((__vector_size__(16))) unsigned int uint4;

// CHECK: @_Z5test1Dv4_j
int4 test1(uint4 V0) {
  // CHECK: [[CMP0:%.*]] = icmp eq <4 x i32> [[V0:%.*]], zeroinitializer
  // CHECK-NEXT: [[V1:%.*]] = sext <4 x i1> [[CMP0]] to <4 x i32>
  int4 V = !V0;
  return V;
}

// CHECK: @_Z5test2Dv4_fS_
int4 test2(float4 V0, float4 V1) {
  // CHECK: [[CMP0:%.*]] = fcmp oeq <4 x float> [[V0:%.*]], zeroinitializer
  // CHECK-NEXT: [[V1:%.*]] = sext <4 x i1> [[CMP0]] to <4 x i32>
  int4 V = !V0;
  return V;
}
```

with options -mavx512vl -O2 (-O1 also works) results in an ICE

g++ /home/worker/llvm/src/clang/test/CodeGen/vector.cpp -mavx512vl -O2

/home/worker/llvm/src/clang/test/CodeGen/vector.cpp: In function ‘int4
test2(float4, float4)’:
/home/worker/llvm/src/clang/test/CodeGen/vector.cpp:21:1: error: unrecognizable
insn:
   21 | }
      | ^
(insn 19 18 15 2 (set (reg/i:V4SI 20 xmm0)
        (subreg:V4SI (reg:V4SF 107) 0))
"/home/worker/llvm/src/clang/test/CodeGen/vector.cpp":21:1 -1
     (expr_list:REG_DEAD (reg:V4SF 107)
        (nil)))
during RTL pass: ira
/home/worker/llvm/src/clang/test/CodeGen/vector.cpp:21:1: internal compiler
error: in extract_insn, at recog.cc:2848
0x1fffbae internal_error(char const*, ...)
       
/home/worker/buildworker/tiber-gcc-trunk-x86_64/build/gcc/diagnostic-global-context.cc:491
0x78154d fancy_abort(char const*, int, char const*)
       
/home/worker/buildworker/tiber-gcc-trunk-x86_64/build/gcc/diagnostic.cc:1725
0x7590c6 _fatal_insn(char const*, rtx_def const*, char const*, int, char
const*)
       
/home/worker/buildworker/tiber-gcc-trunk-x86_64/build/gcc/rtl-error.cc:108
0x7590e2 _fatal_insn_not_found(rtx_def const*, char const*, int, char const*)
       
/home/worker/buildworker/tiber-gcc-trunk-x86_64/build/gcc/rtl-error.cc:116
0x7581be extract_insn(rtx_insn*)
        /home/worker/buildworker/tiber-gcc-trunk-x86_64/build/gcc/recog.cc:2848
0xd0b980 ira_remove_insn_scratches(rtx_insn*, bool, _IO_FILE*, rtx_def*
(*)(rtx_def*))
        /home/worker/buildworker/tiber-gcc-trunk-x86_64/build/gcc/ira.cc:5381
0xd0c2d7 remove_scratches
        /home/worker/buildworker/tiber-gcc-trunk-x86_64/build/gcc/ira.cc:5425
0xd0c2d7 ira
        /home/worker/buildworker/tiber-gcc-trunk-x86_64/build/gcc/ira.cc:5757
0xd0c2d7 execute
        /home/worker/buildworker/tiber-gcc-trunk-x86_64/build/gcc/ira.cc:6117
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.


Observed on AMD Zen2 machine. Compiler configuration:

Using built-in specs.
COLLECT_GCC=/home/worker/cross/bin/g++
COLLECT_LTO_WRAPPER=/home/worker/cross/libexec/gcc/x86_64-pc-linux-gnu/15.0.0/lto-wrapper
Target: x86_64-pc-linux-gnu
Configured with:
/home/worker/buildworker/tiber-gcc-trunk-x86_64/build/configure
--enable-languages=c,c++,fortran --disable-bootstrap --disable-libsanitizer
--disable-multilib --enable-checking=release --prefix=/home/worker/cross
Thread model: posix
Supported LTO compression algorithms: zlib zstd
gcc version 15.0.0 20240717 (experimental)
3bbc8ea2e38d194fb5f2f52ab3f75301d4f84f06 (GCC)

Reply via email to