From: DengJianbo Date: Tue, 13 Jan 2026 07:21:54 +0000 (+0800) Subject: LoongArch: Fix ICE when explicit-relocs is none X-Git-Tag: basepoints/gcc-17~2015 X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=a0ee159bb584855ad2db4563b6e31f88cebe055f;p=thirdparty%2Fgcc.git LoongArch: Fix ICE when explicit-relocs is none 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. --- diff --git a/gcc/config/loongarch/loongarch.md b/gcc/config/loongarch/loongarch.md index b96bedefcc4..9dc9d6dffad 100644 --- a/gcc/config/loongarch/loongarch.md +++ b/gcc/config/loongarch/loongarch.md @@ -2382,7 +2382,7 @@ (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 index 00000000000..9fa32a67bf4 --- /dev/null +++ b/gcc/testsuite/gcc.target/loongarch/la64/attr-model-6.c @@ -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"