https://gcc.gnu.org/g:b4fedc3f7c66dc7da2467bda09cfd5d922682491
commit r14-12241-gb4fedc3f7c66dc7da2467bda09cfd5d922682491 Author: DengJianbo <[email protected]> Date: Tue Jan 13 15:21:54 2026 +0800 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/attr-model-6.c: New test. (cherry picked from commit a0ee159bb584855ad2db4563b6e31f88cebe055f) Diff: --- gcc/config/loongarch/loongarch.md | 2 +- gcc/testsuite/gcc.target/loongarch/attr-model-6.c | 8 ++++++++ 2 files changed, 9 insertions(+), 1 deletion(-) diff --git a/gcc/config/loongarch/loongarch.md b/gcc/config/loongarch/loongarch.md index f467e310696e..84fdaa0755be 100644 --- a/gcc/config/loongarch/loongarch.md +++ b/gcc/config/loongarch/loongarch.md @@ -2205,7 +2205,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/attr-model-6.c b/gcc/testsuite/gcc.target/loongarch/attr-model-6.c new file mode 100644 index 000000000000..9fa32a67bf41 --- /dev/null +++ b/gcc/testsuite/gcc.target/loongarch/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"
