public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug rtl-optimization/113690] New: [13/14 Regression] ICE: in as_a, at machmode.h:381 with -O2 -fno-dce -fno-forward-propagate -fno-split-wide-types -funroll-loops
@ 2024-01-31 20:40 zsojka at seznam dot cz
  2024-02-01  1:02 ` [Bug rtl-optimization/113690] " pinskia at gcc dot gnu.org
                   ` (8 more replies)
  0 siblings, 9 replies; 10+ messages in thread
From: zsojka at seznam dot cz @ 2024-01-31 20:40 UTC (permalink / raw)
  To: gcc-bugs

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

            Bug ID: 113690
           Summary: [13/14 Regression] ICE: in as_a, at machmode.h:381
                    with -O2 -fno-dce -fno-forward-propagate
                    -fno-split-wide-types -funroll-loops
           Product: gcc
           Version: 14.0
            Status: UNCONFIRMED
          Keywords: ice-on-valid-code
          Severity: normal
          Priority: P3
         Component: rtl-optimization
          Assignee: unassigned at gcc dot gnu.org
          Reporter: zsojka at seznam dot cz
  Target Milestone: ---
              Host: x86_64-pc-linux-gnu
            Target: x86_64-pc-linux-gnu

Created attachment 57271
  --> https://gcc.gnu.org/bugzilla/attachment.cgi?id=57271&action=edit
reduced testcase

Compiler output:
$ x86_64-pc-linux-gnu-gcc -O2 -fno-dce -fno-forward-propagate
-fno-split-wide-types -funroll-loops testcase.c
during RTL pass: cse2
testcase.c: In function 'foo':
testcase.c:10:1: internal compiler error: in as_a, at machmode.h:381
   10 | }
      | ^
0x814e46 scalar_int_mode as_a<scalar_int_mode>(machine_mode)
        /repo/gcc-trunk/gcc/machmode.h:381
0x8196e0 scalar_mode as_a<scalar_mode>(machine_mode)
        /repo/gcc-trunk/gcc/simplify-rtx.cc:3179
0x8196e0 wi::int_traits<std::pair<rtx_def*, machine_mode>
>::get_precision(std::pair<rtx_def*, machine_mode> const&)
        /repo/gcc-trunk/gcc/rtl.h:2283
0x8196e0 unsigned int wi::get_precision<std::pair<rtx_def*, machine_mode>
>(std::pair<rtx_def*, machine_mode> const&)
        /repo/gcc-trunk/gcc/wide-int.h:2168
0x8196e0 wide_int_ref_storage<false,
true>::wide_int_ref_storage<std::pair<rtx_def*, machine_mode>
>(std::pair<rtx_def*, machine_mode> const&)
        /repo/gcc-trunk/gcc/wide-int.h:1089
0x8196e0 generic_wide_int<wide_int_ref_storage<false, true>
>::generic_wide_int<std::pair<rtx_def*, machine_mode> >(std::pair<rtx_def*,
machine_mode> const&)
        /repo/gcc-trunk/gcc/wide-int.h:847
0x8196e0 simplify_context::simplify_binary_operation_1(rtx_code, machine_mode,
rtx_def*, rtx_def*, rtx_def*, rtx_def*)
        /repo/gcc-trunk/gcc/simplify-rtx.cc:3338
0x14dd0ad simplify_context::simplify_binary_operation(rtx_code, machine_mode,
rtx_def*, rtx_def*)
        /repo/gcc-trunk/gcc/simplify-rtx.cc:2667
0x26c4a74 simplify_binary_operation(rtx_code, machine_mode, rtx_def*, rtx_def*)
        /repo/gcc-trunk/gcc/rtl.h:3493
0x26c4a74 fold_rtx
        /repo/gcc-trunk/gcc/cse.cc:3719
0x26c5ff2 canonicalize_insn
        /repo/gcc-trunk/gcc/cse.cc:4461
0x26c6511 cse_insn
        /repo/gcc-trunk/gcc/cse.cc:4544
0x26cc0e3 cse_extended_basic_block
        /repo/gcc-trunk/gcc/cse.cc:6574
0x26cc0e3 cse_main
        /repo/gcc-trunk/gcc/cse.cc:6719
0x26ccb00 rest_of_handle_cse2
        /repo/gcc-trunk/gcc/cse.cc:7617
0x26ccb00 execute
        /repo/gcc-trunk/gcc/cse.cc:7672
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.

$ x86_64-pc-linux-gnu-gcc -v
Using built-in specs.
COLLECT_GCC=/repo/gcc-trunk/binary-latest-amd64/bin/x86_64-pc-linux-gnu-gcc
COLLECT_LTO_WRAPPER=/repo/gcc-trunk/binary-trunk-r14-8665-20240131161256-g3fed1609f61-checking-yes-rtl-df-extra-nobootstrap-amd64/bin/../libexec/gcc/x86_64-pc-linux-gnu/14.0.1/lto-wrapper
Target: x86_64-pc-linux-gnu
Configured with: /repo/gcc-trunk//configure --enable-languages=c,c++
--enable-valgrind-annotations --disable-nls --enable-checking=yes,rtl,df,extra
--disable-bootstrap --with-cloog --with-ppl --with-isl
--build=x86_64-pc-linux-gnu --host=x86_64-pc-linux-gnu
--target=x86_64-pc-linux-gnu --with-ld=/usr/bin/x86_64-pc-linux-gnu-ld
--with-as=/usr/bin/x86_64-pc-linux-gnu-as --disable-libstdcxx-pch
--prefix=/repo/gcc-trunk//binary-trunk-r14-8665-20240131161256-g3fed1609f61-checking-yes-rtl-df-extra-nobootstrap-amd64
Thread model: posix
Supported LTO compression algorithms: zlib zstd
gcc version 14.0.1 20240131 (experimental) (GCC)

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

* [Bug rtl-optimization/113690] [13/14 Regression] ICE: in as_a, at machmode.h:381 with -O2 -fno-dce -fno-forward-propagate -fno-split-wide-types -funroll-loops
  2024-01-31 20:40 [Bug rtl-optimization/113690] New: [13/14 Regression] ICE: in as_a, at machmode.h:381 with -O2 -fno-dce -fno-forward-propagate -fno-split-wide-types -funroll-loops zsojka at seznam dot cz
@ 2024-02-01  1:02 ` pinskia at gcc dot gnu.org
  2024-02-01  1:09 ` [Bug target/113690] " pinskia at gcc dot gnu.org
                   ` (7 subsequent siblings)
  8 siblings, 0 replies; 10+ messages in thread
From: pinskia at gcc dot gnu.org @ 2024-02-01  1:02 UTC (permalink / raw)
  To: gcc-bugs

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

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

           What    |Removed                     |Added
----------------------------------------------------------------------------
     Ever confirmed|0                           |1
   Last reconfirmed|                            |2024-02-01
             Status|UNCONFIRMED                 |NEW
   Target Milestone|---                         |13.3

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

Note there is some missed optimizations on the gimple level too ...

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

* [Bug target/113690] [13/14 Regression] ICE: in as_a, at machmode.h:381 with -O2 -fno-dce -fno-forward-propagate -fno-split-wide-types -funroll-loops
  2024-01-31 20:40 [Bug rtl-optimization/113690] New: [13/14 Regression] ICE: in as_a, at machmode.h:381 with -O2 -fno-dce -fno-forward-propagate -fno-split-wide-types -funroll-loops zsojka at seznam dot cz
  2024-02-01  1:02 ` [Bug rtl-optimization/113690] " pinskia at gcc dot gnu.org
@ 2024-02-01  1:09 ` pinskia at gcc dot gnu.org
  2024-02-01  7:45 ` rguenth at gcc dot gnu.org
                   ` (6 subsequent siblings)
  8 siblings, 0 replies; 10+ messages in thread
From: pinskia at gcc dot gnu.org @ 2024-02-01  1:09 UTC (permalink / raw)
  To: gcc-bugs

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

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

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

--- Comment #2 from Andrew Pinski <pinskia at gcc dot gnu.org> ---
(gdb) p debug_rtx(tem)
(expr_list:REG_EQUAL (mult:V1TI (reg:V1TI 101 [ _12 ])
        (const_int 3 [0x3]))
    (nil))


That seems wrong ...


It was introduced by stv1 pass with:
(insn 32 31 33 2 (set (reg:V1TI 132 [ _20 ])
        (reg:V1TI 101 [ _12 ])) "t5.c":9:5 2025 {movv1ti_internal}
     (expr_list:REG_DEAD (reg:V1TI 130 [ BIT_FIELD_REF <v, 128, 128> ])
        (expr_list:REG_DEAD (reg:V1TI 129 [ BIT_FIELD_REF <v, 128, 128> ])
            (expr_list:REG_UNUSED (reg:CC 17 flags)
                (expr_list:REG_EQUAL (mult:V1TI (reg:V1TI 101 [ _12 ])
                        (const_int 3 [0x3]))
                    (nil))))))


Which was before it:
(insn 32 31 33 2 (set (reg:TI 132 [ _20 ])
        (reg:TI 101 [ _12 ])) "t5.c":9:5 83 {*movti_internal}
     (expr_list:REG_DEAD (reg:TI 130 [ BIT_FIELD_REF <v, 128, 128> ])
        (expr_list:REG_DEAD (reg:TI 129 [ BIT_FIELD_REF <v, 128, 128> ])
            (expr_list:REG_UNUSED (reg:CC 17 flags)
                (expr_list:REG_EQUAL (mult:TI (reg:TI 101 [ _12 ])
                        (const_int 3 [0x3]))
                    (nil))))))


it should have been replaced with `(const_vect (const_int 3))`.

So this is a target specific pass which is causing the issue.

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

* [Bug target/113690] [13/14 Regression] ICE: in as_a, at machmode.h:381 with -O2 -fno-dce -fno-forward-propagate -fno-split-wide-types -funroll-loops
  2024-01-31 20:40 [Bug rtl-optimization/113690] New: [13/14 Regression] ICE: in as_a, at machmode.h:381 with -O2 -fno-dce -fno-forward-propagate -fno-split-wide-types -funroll-loops zsojka at seznam dot cz
  2024-02-01  1:02 ` [Bug rtl-optimization/113690] " pinskia at gcc dot gnu.org
  2024-02-01  1:09 ` [Bug target/113690] " pinskia at gcc dot gnu.org
@ 2024-02-01  7:45 ` rguenth at gcc dot gnu.org
  2024-02-01 14:28 ` hjl.tools at gmail dot com
                   ` (5 subsequent siblings)
  8 siblings, 0 replies; 10+ messages in thread
From: rguenth at gcc dot gnu.org @ 2024-02-01  7:45 UTC (permalink / raw)
  To: gcc-bugs

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

Richard Biener <rguenth at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
           Priority|P3                          |P2

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

* [Bug target/113690] [13/14 Regression] ICE: in as_a, at machmode.h:381 with -O2 -fno-dce -fno-forward-propagate -fno-split-wide-types -funroll-loops
  2024-01-31 20:40 [Bug rtl-optimization/113690] New: [13/14 Regression] ICE: in as_a, at machmode.h:381 with -O2 -fno-dce -fno-forward-propagate -fno-split-wide-types -funroll-loops zsojka at seznam dot cz
                   ` (2 preceding siblings ...)
  2024-02-01  7:45 ` rguenth at gcc dot gnu.org
@ 2024-02-01 14:28 ` hjl.tools at gmail dot com
  2024-02-01 22:21 ` roger at nextmovesoftware dot com
                   ` (4 subsequent siblings)
  8 siblings, 0 replies; 10+ messages in thread
From: hjl.tools at gmail dot com @ 2024-02-01 14:28 UTC (permalink / raw)
  To: gcc-bugs

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

H.J. Lu <hjl.tools at gmail dot com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
           Keywords|needs-bisection             |

--- Comment #3 from H.J. Lu <hjl.tools at gmail dot com> ---
It is caused by r13-2050

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

* [Bug target/113690] [13/14 Regression] ICE: in as_a, at machmode.h:381 with -O2 -fno-dce -fno-forward-propagate -fno-split-wide-types -funroll-loops
  2024-01-31 20:40 [Bug rtl-optimization/113690] New: [13/14 Regression] ICE: in as_a, at machmode.h:381 with -O2 -fno-dce -fno-forward-propagate -fno-split-wide-types -funroll-loops zsojka at seznam dot cz
                   ` (3 preceding siblings ...)
  2024-02-01 14:28 ` hjl.tools at gmail dot com
@ 2024-02-01 22:21 ` roger at nextmovesoftware dot com
  2024-02-07 14:22 ` cvs-commit at gcc dot gnu.org
                   ` (3 subsequent siblings)
  8 siblings, 0 replies; 10+ messages in thread
From: roger at nextmovesoftware dot com @ 2024-02-01 22:21 UTC (permalink / raw)
  To: gcc-bugs

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

Roger Sayle <roger at nextmovesoftware dot com> changed:

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

--- Comment #4 from Roger Sayle <roger at nextmovesoftware dot com> ---
I'm bootstrapping and regression testing a fix.

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

* [Bug target/113690] [13/14 Regression] ICE: in as_a, at machmode.h:381 with -O2 -fno-dce -fno-forward-propagate -fno-split-wide-types -funroll-loops
  2024-01-31 20:40 [Bug rtl-optimization/113690] New: [13/14 Regression] ICE: in as_a, at machmode.h:381 with -O2 -fno-dce -fno-forward-propagate -fno-split-wide-types -funroll-loops zsojka at seznam dot cz
                   ` (4 preceding siblings ...)
  2024-02-01 22:21 ` roger at nextmovesoftware dot com
@ 2024-02-07 14:22 ` cvs-commit at gcc dot gnu.org
  2024-02-16  9:07 ` [Bug target/113690] [13 " roger at nextmovesoftware dot com
                   ` (2 subsequent siblings)
  8 siblings, 0 replies; 10+ messages in thread
From: cvs-commit at gcc dot gnu.org @ 2024-02-07 14:22 UTC (permalink / raw)
  To: gcc-bugs

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

--- Comment #5 from GCC Commits <cvs-commit at gcc dot gnu.org> ---
The master branch has been updated by Roger Sayle <sayle@gcc.gnu.org>:

https://gcc.gnu.org/g:99200573096c03120c8d4514383951acecdd5ab1

commit r14-8868-g99200573096c03120c8d4514383951acecdd5ab1
Author: Roger Sayle <roger@nextmovesoftware.com>
Date:   Wed Feb 7 14:21:34 2024 +0000

    PR target/113690: Remove TImode REG_EQUAL notes in STV.

    This patch fixes PR target/113690, an ICE-on-valid regression on x86_64
    that exhibits with a specific combination of command line options.  The
    cause is that x86's scalar-to-vector pass converts a chain of instructions
    from TImode to V1TImode, but fails to appropriately update or delete the
    attached REG_EQUAL note.  This implements Uros' recommendation of removing
    these notes.  For convenience, this code (re)factors the logic to convert
    a TImode constant into a V1TImode constant vector into a subroutine and
    reuses it.

    For the record, STV is actually doing something useful in this strange
    testcase,  GCC with -O2 -fno-dce -fno-forward-propagate
-fno-split-wide-types
    -funroll-loops generates:

    foo:    movl    $v, %eax
            pxor    %xmm0, %xmm0
            movaps  %xmm0, 48(%rax)
            movaps  %xmm0, (%rax)
            movaps  %xmm0, 16(%rax)
            movaps  %xmm0, 32(%rax)
            ret

    With the addition of -mno-stv (to disable the patched code) it gives:

    foo:    movl    $v, %eax
            movq    $0, 48(%rax)
            movq    $0, 56(%rax)
            movq    $0, (%rax)
            movq    $0, 8(%rax)
            movq    $0, 16(%rax)
            movq    $0, 24(%rax)
            movq    $0, 32(%rax)
            movq    $0, 40(%rax)
            ret

    2024-02-07  Roger Sayle  <roger@nextmovesoftware.com>
                Uros Bizjak  <ubizjak@gmail.com>

    gcc/ChangeLog
            PR target/113690
            * config/i386/i386-features.cc (timode_convert_cst): New helper
            function to convert a TImode CONST_SCALAR_INT_P to a V1TImode
            CONST_VECTOR.
            (timode_scalar_chain::convert_op): Use timode_convert_cst.
            (timode_scalar_chain::convert_insn): Delete REG_EQUAL notes.
            Use timode_convert_cst.

    gcc/testsuite/ChangeLog
            PR target/113690
            * gcc.target/i386/pr113690.c: New test case.

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

* [Bug target/113690] [13 Regression] ICE: in as_a, at machmode.h:381 with -O2 -fno-dce -fno-forward-propagate -fno-split-wide-types -funroll-loops
  2024-01-31 20:40 [Bug rtl-optimization/113690] New: [13/14 Regression] ICE: in as_a, at machmode.h:381 with -O2 -fno-dce -fno-forward-propagate -fno-split-wide-types -funroll-loops zsojka at seznam dot cz
                   ` (5 preceding siblings ...)
  2024-02-07 14:22 ` cvs-commit at gcc dot gnu.org
@ 2024-02-16  9:07 ` roger at nextmovesoftware dot com
  2024-05-08 12:23 ` rguenth at gcc dot gnu.org
  2024-05-21  9:18 ` jakub at gcc dot gnu.org
  8 siblings, 0 replies; 10+ messages in thread
From: roger at nextmovesoftware dot com @ 2024-02-16  9:07 UTC (permalink / raw)
  To: gcc-bugs

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

Roger Sayle <roger at nextmovesoftware dot com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
            Summary|[13/14 Regression] ICE: in  |[13 Regression] ICE: in
                   |as_a, at machmode.h:381     |as_a, at machmode.h:381
                   |with -O2 -fno-dce           |with -O2 -fno-dce
                   |-fno-forward-propagate      |-fno-forward-propagate
                   |-fno-split-wide-types       |-fno-split-wide-types
                   |-funroll-loops              |-funroll-loops

--- Comment #6 from Roger Sayle <roger at nextmovesoftware dot com> ---
This has now been fixed on mainline.  Please let me know if this is worth
backporting to GCC 13.

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

* [Bug target/113690] [13 Regression] ICE: in as_a, at machmode.h:381 with -O2 -fno-dce -fno-forward-propagate -fno-split-wide-types -funroll-loops
  2024-01-31 20:40 [Bug rtl-optimization/113690] New: [13/14 Regression] ICE: in as_a, at machmode.h:381 with -O2 -fno-dce -fno-forward-propagate -fno-split-wide-types -funroll-loops zsojka at seznam dot cz
                   ` (6 preceding siblings ...)
  2024-02-16  9:07 ` [Bug target/113690] [13 " roger at nextmovesoftware dot com
@ 2024-05-08 12:23 ` rguenth at gcc dot gnu.org
  2024-05-21  9:18 ` jakub at gcc dot gnu.org
  8 siblings, 0 replies; 10+ messages in thread
From: rguenth at gcc dot gnu.org @ 2024-05-08 12:23 UTC (permalink / raw)
  To: gcc-bugs

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

--- Comment #7 from Richard Biener <rguenth at gcc dot gnu.org> ---
I think it's worth backporting if there was no known fallout from the change.

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

* [Bug target/113690] [13 Regression] ICE: in as_a, at machmode.h:381 with -O2 -fno-dce -fno-forward-propagate -fno-split-wide-types -funroll-loops
  2024-01-31 20:40 [Bug rtl-optimization/113690] New: [13/14 Regression] ICE: in as_a, at machmode.h:381 with -O2 -fno-dce -fno-forward-propagate -fno-split-wide-types -funroll-loops zsojka at seznam dot cz
                   ` (7 preceding siblings ...)
  2024-05-08 12:23 ` rguenth at gcc dot gnu.org
@ 2024-05-21  9:18 ` jakub at gcc dot gnu.org
  8 siblings, 0 replies; 10+ messages in thread
From: jakub at gcc dot gnu.org @ 2024-05-21  9:18 UTC (permalink / raw)
  To: gcc-bugs

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

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

           What    |Removed                     |Added
----------------------------------------------------------------------------
   Target Milestone|13.3                        |13.4

--- Comment #8 from Jakub Jelinek <jakub at gcc dot gnu.org> ---
GCC 13.3 is being released, retargeting bugs to GCC 13.4.

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

end of thread, other threads:[~2024-05-21  9:18 UTC | newest]

Thread overview: 10+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2024-01-31 20:40 [Bug rtl-optimization/113690] New: [13/14 Regression] ICE: in as_a, at machmode.h:381 with -O2 -fno-dce -fno-forward-propagate -fno-split-wide-types -funroll-loops zsojka at seznam dot cz
2024-02-01  1:02 ` [Bug rtl-optimization/113690] " pinskia at gcc dot gnu.org
2024-02-01  1:09 ` [Bug target/113690] " pinskia at gcc dot gnu.org
2024-02-01  7:45 ` rguenth at gcc dot gnu.org
2024-02-01 14:28 ` hjl.tools at gmail dot com
2024-02-01 22:21 ` roger at nextmovesoftware dot com
2024-02-07 14:22 ` cvs-commit at gcc dot gnu.org
2024-02-16  9:07 ` [Bug target/113690] [13 " roger at nextmovesoftware dot com
2024-05-08 12:23 ` rguenth at gcc dot gnu.org
2024-05-21  9:18 ` 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).