https://gcc.gnu.org/bugzilla/show_bug.cgi?id=121542
--- Comment #2 from chenglulu <chenglulu at loongson dot cn> --- The parameter vectype of the function loongarch_vector_costs::add_stmt_cost may be NULL, but there is a place in the function that does not check whether vectype is NULL and uses it directly, resulting in ICE. The following modification can fix this problem. ``` diff --git a/gcc/config/loongarch/loongarch.cc b/gcc/config/loongarch/loongarch.cc index 493f95e1619..80ffc206d05 100644 --- a/gcc/config/loongarch/loongarch.cc +++ b/gcc/config/loongarch/loongarch.cc @@ -4388,7 +4388,8 @@ loongarch_vector_costs::add_stmt_cost (int count, vect_cost_for_stmt kind, break; } else if (TARGET_RECIP_VEC_DIV - && gimple_code (stmt_info->stmt) == GIMPLE_ASSIGN) + && gimple_code (stmt_info->stmt) == GIMPLE_ASSIGN + && vectype) { machine_mode mode = TYPE_MODE (vectype); switch (gimple_assign_rhs_code (stmt_info->stmt)) ```