]> git.ipfire.org Git - thirdparty/gcc.git/commitdiff
LoongArch: Fix ICE when explicit-relocs is none
authorDengJianbo <dengjianbo@loongson.cn>
Tue, 13 Jan 2026 07:21:54 +0000 (15:21 +0800)
committerLulu Cheng <chenglulu@loongson.cn>
Thu, 15 Jan 2026 02:55:27 +0000 (10:55 +0800)
When set -mexplicit-relocs=none, the symbol address should be caclulated
by macro instructions, for example la.local. Due to the condition
TARGET_CMODEL_EXTREME in movdi_symbolic_off64, this template can not be
matched in case the cmodel is normal. If the variable has attribute
model("extreme"), gcc will get crashed with error unrecognizable insns.
This patch fix this issue by removing TARGET_CMODEL_EXTREME, since it
already checked in prediction symbolic_off64_or_reg_operand.

gcc/ChangeLog:

* config/loongarch/loongarch.md: Remove condition in template
movdi_symbolic_off64.

gcc/testsuite/ChangeLog:

* gcc.target/loongarch/la64/attr-model-6.c: New test.

gcc/config/loongarch/loongarch.md
gcc/testsuite/gcc.target/loongarch/la64/attr-model-6.c [new file with mode: 0644]

index b96bedefcc4f3d243cec34f492bb64fac8b303d7..9dc9d6dffad153bb7ac944fae3abaec622201632 100644 (file)
   (unspec:DI [(const_int 0)]
     UNSPEC_LOAD_SYMBOL_OFFSET64)
   (clobber (match_operand:DI 2 "register_operand" "=&r,r"))]
- "TARGET_64BIT && TARGET_CMODEL_EXTREME"
+ "TARGET_64BIT"
 {
   if (which_alternative == 1)
     return "#";
diff --git a/gcc/testsuite/gcc.target/loongarch/la64/attr-model-6.c b/gcc/testsuite/gcc.target/loongarch/la64/attr-model-6.c
new file mode 100644 (file)
index 0000000..9fa32a6
--- /dev/null
@@ -0,0 +1,8 @@
+/* { dg-do compile } */
+/* { dg-options "-mexplicit-relocs=none -mcmodel=normal -O2 -fno-pic" } */
+/* { dg-final { scan-assembler "la.local\t\\\$r\[0-9\]+,\\\$r\[0-9\]+,x" } } */
+/* { dg-final { scan-assembler "la.local\t\\\$r\[0-9\]+,y" } } */
+/* { dg-final { scan-assembler "la.local\t\\\$r\[0-9\]+,\\\$r\[0-9\]+,counter" } } */
+
+#define ATTR_MODEL_TEST
+#include "attr-model-test.c"