public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug rtl-optimization/115982] New: ICE: unrecognizable insn in ira_remove_insn_scratches with -mavx512vl
@ 2024-07-18 10:08 pheeck at gcc dot gnu.org
  2024-07-18 11:32 ` [Bug rtl-optimization/115982] " pheeck at gcc dot gnu.org
                   ` (6 more replies)
  0 siblings, 7 replies; 8+ messages in thread
From: pheeck at gcc dot gnu.org @ 2024-07-18 10:08 UTC (permalink / raw)
  To: gcc-bugs

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)

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

* [Bug rtl-optimization/115982] ICE: unrecognizable insn in ira_remove_insn_scratches with -mavx512vl
  2024-07-18 10:08 [Bug rtl-optimization/115982] New: ICE: unrecognizable insn in ira_remove_insn_scratches with -mavx512vl pheeck at gcc dot gnu.org
@ 2024-07-18 11:32 ` pheeck at gcc dot gnu.org
  2024-07-18 17:39 ` [Bug target/115982] " pinskia at gcc dot gnu.org
                   ` (5 subsequent siblings)
  6 siblings, 0 replies; 8+ messages in thread
From: pheeck at gcc dot gnu.org @ 2024-07-18 11:32 UTC (permalink / raw)
  To: gcc-bugs

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

Filip Kastl <pheeck at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
   Target Milestone|---                         |15.0

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

* [Bug target/115982] ICE: unrecognizable insn in ira_remove_insn_scratches with -mavx512vl
  2024-07-18 10:08 [Bug rtl-optimization/115982] New: ICE: unrecognizable insn in ira_remove_insn_scratches with -mavx512vl pheeck at gcc dot gnu.org
  2024-07-18 11:32 ` [Bug rtl-optimization/115982] " pheeck at gcc dot gnu.org
@ 2024-07-18 17:39 ` pinskia at gcc dot gnu.org
  2024-07-18 17:47 ` pinskia at gcc dot gnu.org
                   ` (4 subsequent siblings)
  6 siblings, 0 replies; 8+ messages in thread
From: pinskia at gcc dot gnu.org @ 2024-07-18 17:39 UTC (permalink / raw)
  To: gcc-bugs

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

Andrew Pinski <pinskia at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
           Keywords|ra                          |
          Component|rtl-optimization            |target

--- Comment #1 from Andrew Pinski <pinskia at gcc dot gnu.org> ---
IRA is the first pass after split1 that runs recog on the instructions. So that
is why ira is mentioned.

split1 splits:
```
(insn 17 13 18 2 (set (reg/i:V4SI 20 xmm0)
        (vec_merge:V4SI (const_vector:V4SI [
                    (const_int -1 [0xffffffffffffffff]) repeated x4
                ])
            (const_vector:V4SI [
                    (const_int 0 [0]) repeated x4
                ])
            (unspec:QI [
                    (reg:V4SF 106)
                    (reg:V4SF 102)
                    (const_int 0 [0])
                ] UNSPEC_PCMP))) "/app/example.cpp":20:1 2929 {*avx_cmpv4sf3_1}
     (expr_list:REG_DEAD (reg:V4SF 102)
        (expr_list:REG_DEAD (reg:V4SF 106)
            (nil))))
```

into:
```
(insn 23 13 24 2 (set (reg:V4SF 107)
        (unspec:V4SF [
                (reg:V4SF 106)
                (reg:V4SF 102)
                (const_int 0 [0])
            ] UNSPEC_PCMP)) "/app/example.cpp":20:1 -1
     (nil))
(insn 24 23 18 2 (set (reg/i:V4SI 20 xmm0)
        (subreg:V4SI (reg:V4SF 107) 0)) "/app/example.cpp":20:1 -1
     (nil))
```

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

* [Bug target/115982] ICE: unrecognizable insn in ira_remove_insn_scratches with -mavx512vl
  2024-07-18 10:08 [Bug rtl-optimization/115982] New: ICE: unrecognizable insn in ira_remove_insn_scratches with -mavx512vl pheeck at gcc dot gnu.org
  2024-07-18 11:32 ` [Bug rtl-optimization/115982] " pheeck at gcc dot gnu.org
  2024-07-18 17:39 ` [Bug target/115982] " pinskia at gcc dot gnu.org
@ 2024-07-18 17:47 ` pinskia at gcc dot gnu.org
  2024-07-19 14:52 ` [Bug target/115982] [15 Regression] ICE: unrecognizable insn in ira_remove_insn_scratches with -mavx512vl since r15-1742 jakub at gcc dot gnu.org
                   ` (3 subsequent siblings)
  6 siblings, 0 replies; 8+ messages in thread
From: pinskia at gcc dot gnu.org @ 2024-07-18 17:47 UTC (permalink / raw)
  To: gcc-bugs

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

Andrew Pinski <pinskia at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
   Last reconfirmed|                            |2024-07-18
           Keywords|                            |needs-bisection
     Ever confirmed|0                           |1
             Status|UNCONFIRMED                 |NEW

--- Comment #2 from Andrew Pinski <pinskia at gcc dot gnu.org> ---
Confirmed.

The split for avx_cmpv4sf3_1 has not changed since r11-6849-gee78c20e74d302 . I
don't know why it is only showing up now.

This will work around it.
```
diff --git a/gcc/config/i386/sse.md b/gcc/config/i386/sse.md
index c134494cd20..cebfc3b1e6b 100644
--- a/gcc/config/i386/sse.md
+++ b/gcc/config/i386/sse.md
@@ -3873,9 +3873,11 @@ (define_insn_and_split "*avx_cmp<mode>3_1"
           (match_dup 4)
           (match_dup 5)]
          UNSPEC_PCMP))
-   (set (match_dup 0) (match_dup 7))]
+   (set (match_dup 8) (match_dup 7))]
+   (set (match_dup 0) (match_dup 8))]
 {
   operands[6] = gen_reg_rtx (<MODE>mode);
+  operands[8] = gen_reg_rtx (GET_MODE (operands[0]));
   operands[7]
     = lowpart_subreg (GET_MODE (operands[0]), operands[6], <MODE>mode);
 })

```

But I am not 100% sure it is the correct fix.

Note only test2 is needed here to get the ICE.

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

* [Bug target/115982] [15 Regression] ICE: unrecognizable insn in ira_remove_insn_scratches with -mavx512vl since r15-1742
  2024-07-18 10:08 [Bug rtl-optimization/115982] New: ICE: unrecognizable insn in ira_remove_insn_scratches with -mavx512vl pheeck at gcc dot gnu.org
                   ` (2 preceding siblings ...)
  2024-07-18 17:47 ` pinskia at gcc dot gnu.org
@ 2024-07-19 14:52 ` jakub at gcc dot gnu.org
  2024-07-22  2:20 ` liuhongt at gcc dot gnu.org
                   ` (2 subsequent siblings)
  6 siblings, 0 replies; 8+ messages in thread
From: jakub at gcc dot gnu.org @ 2024-07-19 14:52 UTC (permalink / raw)
  To: gcc-bugs

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

Jakub Jelinek <jakub at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |jakub at gcc dot gnu.org,
                   |                            |liuhongt at gcc dot gnu.org
            Summary|ICE: unrecognizable insn in |[15 Regression] ICE:
                   |ira_remove_insn_scratches   |unrecognizable insn in
                   |with -mavx512vl             |ira_remove_insn_scratches
                   |                            |with -mavx512vl since
                   |                            |r15-1742

--- Comment #3 from Jakub Jelinek <jakub at gcc dot gnu.org> ---
Simplified testcase:
typedef float VF __attribute__((__vector_size__(16)));
typedef int VI __attribute__((__vector_size__(16)));

VI
foo (VF x)
{
  return !x;
}

Started with r15-1742-g55f80c690c5fa59836646565a9dee2a3f68374a0

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

* [Bug target/115982] [15 Regression] ICE: unrecognizable insn in ira_remove_insn_scratches with -mavx512vl since r15-1742
  2024-07-18 10:08 [Bug rtl-optimization/115982] New: ICE: unrecognizable insn in ira_remove_insn_scratches with -mavx512vl pheeck at gcc dot gnu.org
                   ` (3 preceding siblings ...)
  2024-07-19 14:52 ` [Bug target/115982] [15 Regression] ICE: unrecognizable insn in ira_remove_insn_scratches with -mavx512vl since r15-1742 jakub at gcc dot gnu.org
@ 2024-07-22  2:20 ` liuhongt at gcc dot gnu.org
  2024-07-23  5:54 ` liuhongt at gcc dot gnu.org
  2024-08-19  5:34 ` liuhongt at gcc dot gnu.org
  6 siblings, 0 replies; 8+ messages in thread
From: liuhongt at gcc dot gnu.org @ 2024-07-22  2:20 UTC (permalink / raw)
  To: gcc-bugs

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

Hongtao Liu <liuhongt at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|NEW                         |ASSIGNED
           Assignee|unassigned at gcc dot gnu.org      |liuhongt at gcc dot gnu.org

--- Comment #4 from Hongtao Liu <liuhongt at gcc dot gnu.org> ---
I'll take a look

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

* [Bug target/115982] [15 Regression] ICE: unrecognizable insn in ira_remove_insn_scratches with -mavx512vl since r15-1742
  2024-07-18 10:08 [Bug rtl-optimization/115982] New: ICE: unrecognizable insn in ira_remove_insn_scratches with -mavx512vl pheeck at gcc dot gnu.org
                   ` (4 preceding siblings ...)
  2024-07-22  2:20 ` liuhongt at gcc dot gnu.org
@ 2024-07-23  5:54 ` liuhongt at gcc dot gnu.org
  2024-08-19  5:34 ` liuhongt at gcc dot gnu.org
  6 siblings, 0 replies; 8+ messages in thread
From: liuhongt at gcc dot gnu.org @ 2024-07-23  5:54 UTC (permalink / raw)
  To: gcc-bugs

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

--- Comment #5 from Hongtao Liu <liuhongt at gcc dot gnu.org> ---
Fixed by r15-2217-ga3f03891065cb9, could be latent on release branch since
GCC12

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

* [Bug target/115982] [15 Regression] ICE: unrecognizable insn in ira_remove_insn_scratches with -mavx512vl since r15-1742
  2024-07-18 10:08 [Bug rtl-optimization/115982] New: ICE: unrecognizable insn in ira_remove_insn_scratches with -mavx512vl pheeck at gcc dot gnu.org
                   ` (5 preceding siblings ...)
  2024-07-23  5:54 ` liuhongt at gcc dot gnu.org
@ 2024-08-19  5:34 ` liuhongt at gcc dot gnu.org
  6 siblings, 0 replies; 8+ messages in thread
From: liuhongt at gcc dot gnu.org @ 2024-08-19  5:34 UTC (permalink / raw)
  To: gcc-bugs

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

Hongtao Liu <liuhongt at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
         Resolution|---                         |FIXED
      Known to fail|                            |15.0
      Known to work|                            |15.0
             Status|ASSIGNED                    |RESOLVED

--- Comment #6 from Hongtao Liu <liuhongt at gcc dot gnu.org> ---
Fixed in GCC15.

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

end of thread, other threads:[~2024-08-19  5:34 UTC | newest]

Thread overview: 8+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2024-07-18 10:08 [Bug rtl-optimization/115982] New: ICE: unrecognizable insn in ira_remove_insn_scratches with -mavx512vl pheeck at gcc dot gnu.org
2024-07-18 11:32 ` [Bug rtl-optimization/115982] " pheeck at gcc dot gnu.org
2024-07-18 17:39 ` [Bug target/115982] " pinskia at gcc dot gnu.org
2024-07-18 17:47 ` pinskia at gcc dot gnu.org
2024-07-19 14:52 ` [Bug target/115982] [15 Regression] ICE: unrecognizable insn in ira_remove_insn_scratches with -mavx512vl since r15-1742 jakub at gcc dot gnu.org
2024-07-22  2:20 ` liuhongt at gcc dot gnu.org
2024-07-23  5:54 ` liuhongt at gcc dot gnu.org
2024-08-19  5:34 ` liuhongt 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).