https://gcc.gnu.org/bugzilla/show_bug.cgi?id=118561
--- Comment #4 from chenglulu <chenglulu at loongson dot cn> ---
In the above test cases, target is always NULL_RTX. When an illegal built-in
call occurs, we return this NULL_RTX, but after returning, do not check whether
the returned value is NULL(eg:expr.cc +9858), which leads to ICE.
Therefore, when an illegal built-in function call occurs, returning const0_rtx
can solve the problem.
I'm not sure if this modification is correct.
diff --git a/gcc/config/loongarch/loongarch-builtins.cc
b/gcc/config/loongarch/loongarch-builtins.cc
index 92d995a916a..6dd7201e6b9 100644
--- a/gcc/config/loongarch/loongarch-builtins.cc
+++ b/gcc/config/loongarch/loongarch-builtins.cc
@@ -3036,7 +3036,7 @@ loongarch_expand_builtin (tree exp, rtx target, rtx
subtarget ATTRIBUTE_UNUSED,
{
error_at (EXPR_LOCATION (exp),
"built-in function %qD is not enabled", fndecl);
- return target;
+ return target ? target : const0_rtx;
}