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

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

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Target|                            |loongarch64-linux-gnu
           Keywords|                            |ice-on-valid-code,
                   |                            |needs-reduction

--- Comment #2 from Xi Ruoyao <xry111 at gcc dot gnu.org> ---
Tentative patch:

>From b7a57d60ae132783e53dde156beb749ac0172643 Mon Sep 17 00:00:00 2001
From: Xi Ruoyao <xry...@xry111.site>
Date: Tue, 24 Jun 2025 21:07:55 +0800
Subject: [PATCH] LoongArch: Prevent subreg of subreg in CRC

The register_operand predicate can match subreg, then we'd have a subreg
of subreg and it's invalid.  Use lowpart_subreg to avoid the nested
 subreg.

gcc/ChangeLog:

        * config/loongarch/loongarch.md (crc_combine): Avoid nested
        subreg.
---
 gcc/config/loongarch/loongarch.md | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/gcc/config/loongarch/loongarch.md
b/gcc/config/loongarch/loongarch.md
index a13398fdff4..8cf2ac90c64 100644
--- a/gcc/config/loongarch/loongarch.md
+++ b/gcc/config/loongarch/loongarch.md
@@ -4603,9 +4603,10 @@
   "&& true"
   [(set (match_dup 3) (match_dup 2))
    (set (match_dup 0)
-       (unspec:SI [(match_dup 3) (subreg:SI (match_dup 1) 0)] CRC))]
+       (unspec:SI [(match_dup 3) (match_dup 1)] CRC))]
   {
     operands[3] = gen_reg_rtx (<MODE>mode);
+    operands[1] = lowpart_subreg (SImode, operands[1], DImode);
   })

 ;; With normal or medium code models, if the only use of a pc-relative
-- 
2.50.0

Needing a test case reduced from the preprocessed file before submitting the
patch.

Reply via email to