]> git.ipfire.org Git - thirdparty/gcc.git/commitdiff
LoongArch: Fix the "%t" modifier handling for (const_int 0)
authorXi Ruoyao <xry111@xry111.site>
Tue, 19 Aug 2025 03:14:42 +0000 (11:14 +0800)
committerXi Ruoyao <xry111@xry111.site>
Thu, 11 Sep 2025 10:49:33 +0000 (18:49 +0800)
This modifier is intended to output $r0 for (const_int 0), but the
logic:

GET_MODE (op) != TImode || (op != CONST0_RTX (TImode) && code != REG)

will reject (const_int 0) because (const_int 0) actually does not have
a mode and GET_MODE will return VOIDmode for it.

Use reg_or_0_operand instead to fix the issue.

gcc/ChangeLog:

* config/loongarch/loongarch.cc (loongarch_print_operand): Call
reg_or_0_operand for checking the sanity of %t.

gcc/config/loongarch/loongarch.cc

index 0935d7ba092510f298372aac59dafbc9c563ddcb..ef5d5f4e0605563f16609996613beba62d5242fe 100644 (file)
@@ -6495,8 +6495,7 @@ loongarch_print_operand (FILE *file, rtx op, int letter)
       break;
 
     case 't':
-      if (GET_MODE (op) != TImode
-         || (op != CONST0_RTX (TImode) && code != REG))
+      if (!reg_or_0_operand (op, TImode))
        {
          output_operand_lossage ("invalid use of '%%%c'", letter);
          break;