public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug rtl-optimization/112476] New: [14 Regression] unrecognizable insn with -O2 -march=la464 on loongarch64
@ 2023-11-10 11:58 xen0n at gentoo dot org
  2023-11-10 13:41 ` [Bug rtl-optimization/112476] Unrecognizable " xry111 at gcc dot gnu.org
                   ` (6 more replies)
  0 siblings, 7 replies; 8+ messages in thread
From: xen0n at gentoo dot org @ 2023-11-10 11:58 UTC (permalink / raw)
  To: gcc-bugs

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

            Bug ID: 112476
           Summary: [14 Regression] unrecognizable insn with -O2
                    -march=la464 on loongarch64
           Product: gcc
           Version: 14.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: rtl-optimization
          Assignee: unassigned at gcc dot gnu.org
          Reporter: xen0n at gentoo dot org
  Target Milestone: ---
            Target: loongarch64-linux-gnu

Created attachment 56551
  --> https://gcc.gnu.org/bugzilla/attachment.cgi?id=56551&action=edit
Minimized reproducer

The attached code minified from Skia, ICEs with "unrecognizable insn" when
compiled with SIMD apparently active and the backend wanting to do something
with it.

According to my preliminary debugging: the bug disappears when the extra layer
of wrapping function is removed, when the two "&a" arguments get changed, and
when the memcpy is rewritten to a simple pointer dereference.

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

* [Bug rtl-optimization/112476] Unrecognizable insn with -O2 -march=la464 on loongarch64
  2023-11-10 11:58 [Bug rtl-optimization/112476] New: [14 Regression] unrecognizable insn with -O2 -march=la464 on loongarch64 xen0n at gentoo dot org
@ 2023-11-10 13:41 ` xry111 at gcc dot gnu.org
  2023-11-11 10:32 ` xry111 at gcc dot gnu.org
                   ` (5 subsequent siblings)
  6 siblings, 0 replies; 8+ messages in thread
From: xry111 at gcc dot gnu.org @ 2023-11-10 13:41 UTC (permalink / raw)
  To: gcc-bugs

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

Xi Ruoyao <xry111 at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |xry111 at gcc dot gnu.org
           Keywords|                            |ice-on-valid-code
            Summary|[14 Regression]             |Unrecognizable insn with
                   |unrecognizable insn with    |-O2 -march=la464 on
                   |-O2 -march=la464 on         |loongarch64
                   |loongarch64                 |

--- Comment #1 from Xi Ruoyao <xry111 at gcc dot gnu.org> ---
It's not a regression because GCC 13 does not support LSX.

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

* [Bug rtl-optimization/112476] Unrecognizable insn with -O2 -march=la464 on loongarch64
  2023-11-10 11:58 [Bug rtl-optimization/112476] New: [14 Regression] unrecognizable insn with -O2 -march=la464 on loongarch64 xen0n at gentoo dot org
  2023-11-10 13:41 ` [Bug rtl-optimization/112476] Unrecognizable " xry111 at gcc dot gnu.org
@ 2023-11-11 10:32 ` xry111 at gcc dot gnu.org
  2023-11-11 11:08 ` xry111 at gcc dot gnu.org
                   ` (4 subsequent siblings)
  6 siblings, 0 replies; 8+ messages in thread
From: xry111 at gcc dot gnu.org @ 2023-11-11 10:32 UTC (permalink / raw)
  To: gcc-bugs

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

Xi Ruoyao <xry111 at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
   Last reconfirmed|                            |2023-11-11
             Status|UNCONFIRMED                 |NEW
     Ever confirmed|0                           |1

--- Comment #2 from Xi Ruoyao <xry111 at gcc dot gnu.org> ---
Confirmed with latest master.

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

* [Bug rtl-optimization/112476] Unrecognizable insn with -O2 -march=la464 on loongarch64
  2023-11-10 11:58 [Bug rtl-optimization/112476] New: [14 Regression] unrecognizable insn with -O2 -march=la464 on loongarch64 xen0n at gentoo dot org
  2023-11-10 13:41 ` [Bug rtl-optimization/112476] Unrecognizable " xry111 at gcc dot gnu.org
  2023-11-11 10:32 ` xry111 at gcc dot gnu.org
@ 2023-11-11 11:08 ` xry111 at gcc dot gnu.org
  2023-11-11 16:49 ` [Bug target/112476] " xry111 at gcc dot gnu.org
                   ` (3 subsequent siblings)
  6 siblings, 0 replies; 8+ messages in thread
From: xry111 at gcc dot gnu.org @ 2023-11-11 11:08 UTC (permalink / raw)
  To: gcc-bugs

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

Xi Ruoyao <xry111 at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |chenglulu at loongson dot cn

--- Comment #3 from Xi Ruoyao <xry111 at gcc dot gnu.org> ---
GCC internal says:

     ‘subreg’s of ‘subreg’s are not supported.  Using
     ‘simplify_gen_subreg’ is the recommended way to avoid this problem.

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

* [Bug target/112476] Unrecognizable insn with -O2 -march=la464 on loongarch64
  2023-11-10 11:58 [Bug rtl-optimization/112476] New: [14 Regression] unrecognizable insn with -O2 -march=la464 on loongarch64 xen0n at gentoo dot org
                   ` (2 preceding siblings ...)
  2023-11-11 11:08 ` xry111 at gcc dot gnu.org
@ 2023-11-11 16:49 ` xry111 at gcc dot gnu.org
  2023-11-12  1:02 ` xry111 at gcc dot gnu.org
                   ` (2 subsequent siblings)
  6 siblings, 0 replies; 8+ messages in thread
From: xry111 at gcc dot gnu.org @ 2023-11-11 16:49 UTC (permalink / raw)
  To: gcc-bugs

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

Xi Ruoyao <xry111 at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
          Component|rtl-optimization            |target
             Status|NEW                         |ASSIGNED

--- Comment #4 from Xi Ruoyao <xry111 at gcc dot gnu.org> ---
The buggy nested subreg RTX is generated by LoongArch specific code
loongarch_expand_vec_cond_mask_expr.

Draft patch:

diff --git a/gcc/config/loongarch/loongarch.cc
b/gcc/config/loongarch/loongarch.cc
index d9b7a1076a2..0c7bafb5fb1 100644
--- a/gcc/config/loongarch/loongarch.cc
+++ b/gcc/config/loongarch/loongarch.cc
@@ -11197,7 +11197,9 @@ loongarch_expand_vec_cond_mask_expr (machine_mode mode,
machine_mode vimode,
          if (mode != vimode)
            {
              xop1 = gen_reg_rtx (vimode);
-             emit_move_insn (xop1, gen_rtx_SUBREG (vimode, operands[1], 0));
+             emit_move_insn (xop1,
+                             simplify_gen_subreg (vimode, operands[1],
+                                                  mode, 0));
            }
          emit_move_insn (src1, xop1);
        }
@@ -11214,7 +11216,9 @@ loongarch_expand_vec_cond_mask_expr (machine_mode mode,
machine_mode vimode,
          if (mode != vimode)
            {
              xop2 = gen_reg_rtx (vimode);
-             emit_move_insn (xop2, gen_rtx_SUBREG (vimode, operands[2], 0));
+             emit_move_insn (xop2,
+                             simplify_gen_subreg (vimode, operands[2],
+                                                  mode, 0));
            }
          emit_move_insn (src2, xop2);
        }
@@ -11233,7 +11237,8 @@ loongarch_expand_vec_cond_mask_expr (machine_mode mode,
machine_mode vimode,
                          gen_rtx_AND (vimode, mask, src1));
       /* The result is placed back to a register with the mask.  */
       emit_insn (gen_rtx_SET (mask, bsel));
-      emit_move_insn (operands[0], gen_rtx_SUBREG (mode, mask, 0));
+      emit_move_insn (operands[0], simplify_gen_subreg (mode, mask,
+                                                       vimode, 0));
     }
 }

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

* [Bug target/112476] Unrecognizable insn with -O2 -march=la464 on loongarch64
  2023-11-10 11:58 [Bug rtl-optimization/112476] New: [14 Regression] unrecognizable insn with -O2 -march=la464 on loongarch64 xen0n at gentoo dot org
                   ` (3 preceding siblings ...)
  2023-11-11 16:49 ` [Bug target/112476] " xry111 at gcc dot gnu.org
@ 2023-11-12  1:02 ` xry111 at gcc dot gnu.org
  2023-11-13  6:16 ` cvs-commit at gcc dot gnu.org
  2023-11-13  6:22 ` xry111 at gcc dot gnu.org
  6 siblings, 0 replies; 8+ messages in thread
From: xry111 at gcc dot gnu.org @ 2023-11-12  1:02 UTC (permalink / raw)
  To: gcc-bugs

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

Xi Ruoyao <xry111 at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                URL|                            |https://gcc.gnu.org/piperma
                   |                            |il/gcc-patches/2023-Novembe
                   |                            |r/636156.html

--- Comment #5 from Xi Ruoyao <xry111 at gcc dot gnu.org> ---
Patch: https://gcc.gnu.org/pipermail/gcc-patches/2023-November/636156.html

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

* [Bug target/112476] Unrecognizable insn with -O2 -march=la464 on loongarch64
  2023-11-10 11:58 [Bug rtl-optimization/112476] New: [14 Regression] unrecognizable insn with -O2 -march=la464 on loongarch64 xen0n at gentoo dot org
                   ` (4 preceding siblings ...)
  2023-11-12  1:02 ` xry111 at gcc dot gnu.org
@ 2023-11-13  6:16 ` cvs-commit at gcc dot gnu.org
  2023-11-13  6:22 ` xry111 at gcc dot gnu.org
  6 siblings, 0 replies; 8+ messages in thread
From: cvs-commit at gcc dot gnu.org @ 2023-11-13  6:16 UTC (permalink / raw)
  To: gcc-bugs

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

--- Comment #6 from CVS Commits <cvs-commit at gcc dot gnu.org> ---
The master branch has been updated by Xi Ruoyao <xry111@gcc.gnu.org>:

https://gcc.gnu.org/g:b88500e0bc1e9e3a396ba764f9b701d22a76818f

commit r14-5374-gb88500e0bc1e9e3a396ba764f9b701d22a76818f
Author: Xi Ruoyao <xry111@xry111.site>
Date:   Sun Nov 12 00:55:13 2023 +0800

    LoongArch: Use simplify_gen_subreg instead of gen_rtx_SUBREG in
loongarch_expand_vec_cond_mask_expr [PR112476]

    GCC internal says:

        'subreg's of 'subreg's are not supported.  Using
        'simplify_gen_subreg' is the recommended way to avoid this problem.

    Unfortunately loongarch_expand_vec_cond_mask_expr might create nested
    subreg under certain circumstances, causing an ICE.

    Use simplify_gen_subreg as the internal document suggests.

    gcc/ChangeLog:

            PR target/112476
            * config/loongarch/loongarch.cc
            (loongarch_expand_vec_cond_mask_expr): Call simplify_gen_subreg
            instead of gen_rtx_SUBREG.

    gcc/testsuite/ChangeLog:

            PR target/112476
            * gcc.target/loongarch/pr112476-1.c: New test.
            * gcc.target/loongarch/pr112476-2.c: New test.

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

* [Bug target/112476] Unrecognizable insn with -O2 -march=la464 on loongarch64
  2023-11-10 11:58 [Bug rtl-optimization/112476] New: [14 Regression] unrecognizable insn with -O2 -march=la464 on loongarch64 xen0n at gentoo dot org
                   ` (5 preceding siblings ...)
  2023-11-13  6:16 ` cvs-commit at gcc dot gnu.org
@ 2023-11-13  6:22 ` xry111 at gcc dot gnu.org
  6 siblings, 0 replies; 8+ messages in thread
From: xry111 at gcc dot gnu.org @ 2023-11-13  6:22 UTC (permalink / raw)
  To: gcc-bugs

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

Xi Ruoyao <xry111 at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|ASSIGNED                    |RESOLVED
         Resolution|---                         |FIXED
   Target Milestone|---                         |14.0

--- Comment #7 from Xi Ruoyao <xry111 at gcc dot gnu.org> ---
Fixed for trunk.

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

end of thread, other threads:[~2023-11-13  6:22 UTC | newest]

Thread overview: 8+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2023-11-10 11:58 [Bug rtl-optimization/112476] New: [14 Regression] unrecognizable insn with -O2 -march=la464 on loongarch64 xen0n at gentoo dot org
2023-11-10 13:41 ` [Bug rtl-optimization/112476] Unrecognizable " xry111 at gcc dot gnu.org
2023-11-11 10:32 ` xry111 at gcc dot gnu.org
2023-11-11 11:08 ` xry111 at gcc dot gnu.org
2023-11-11 16:49 ` [Bug target/112476] " xry111 at gcc dot gnu.org
2023-11-12  1:02 ` xry111 at gcc dot gnu.org
2023-11-13  6:16 ` cvs-commit at gcc dot gnu.org
2023-11-13  6:22 ` xry111 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).