aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorLulu Cheng <chenglulu@loongson.cn>2025-08-14 11:59:53 +0800
committerLulu Cheng <chenglulu@loongson.cn>2025-08-15 08:35:08 +0800
commitd1c207a65d25b50e851ab53956271c91e0281ae0 (patch)
tree64658b3fee221d50498245315db0412db7451610
parentb7033568085613009adfca36da8f01306918f863 (diff)
downloadgcc-d1c207a65d25b50e851ab53956271c91e0281ae0.zip
gcc-d1c207a65d25b50e851ab53956271c91e0281ae0.tar.gz
gcc-d1c207a65d25b50e851ab53956271c91e0281ae0.tar.bz2
LoongArch: Fix ICE caused by function add_stmt_cost[PR121542].
PR target/121542 gcc/ChangeLog: * config/loongarch/loongarch.cc (loongarch_vector_costs::add_stmt_cost): When using vectype, first determine whether it is NULL. gcc/testsuite/ChangeLog: * gcc.target/loongarch/pr121542.c: New test.
-rw-r--r--gcc/config/loongarch/loongarch.cc1
-rw-r--r--gcc/testsuite/gcc.target/loongarch/pr121542.c54
2 files changed, 55 insertions, 0 deletions
diff --git a/gcc/config/loongarch/loongarch.cc b/gcc/config/loongarch/loongarch.cc
index 3b62ed9..e2f8e06 100644
--- a/gcc/config/loongarch/loongarch.cc
+++ b/gcc/config/loongarch/loongarch.cc
@@ -4388,6 +4388,7 @@ loongarch_vector_costs::add_stmt_cost (int count, vect_cost_for_stmt kind,
break;
}
else if (TARGET_RECIP_VEC_DIV
+ && vectype
&& gimple_code (stmt_info->stmt) == GIMPLE_ASSIGN)
{
machine_mode mode = TYPE_MODE (vectype);
diff --git a/gcc/testsuite/gcc.target/loongarch/pr121542.c b/gcc/testsuite/gcc.target/loongarch/pr121542.c
new file mode 100644
index 0000000..51a5e3c
--- /dev/null
+++ b/gcc/testsuite/gcc.target/loongarch/pr121542.c
@@ -0,0 +1,54 @@
+/* { dg-do compile } */
+/* { dg-options "-mrecip=all -mfrecipe -mabi=lp64d -march=loongarch64 -mfpu=64 -msimd=lasx -Ofast" } */
+
+typedef long unsigned int STRLEN;
+typedef struct sv SV;
+struct sv
+{
+ void *sv_any;
+ unsigned int sv_refcnt;
+ unsigned int sv_flags;
+};
+typedef struct xpv XPV;
+struct xpv
+{
+ char *xpv_pv;
+ STRLEN xpv_cur;
+ STRLEN xpv_len;
+};
+typedef unsigned long UV;
+extern char *PL_bufend;
+extern char *d;
+SV *Perl_newSV (STRLEN len);
+
+char *
+S_scan_const (char *start)
+{
+ register char *send = PL_bufend;
+ SV *sv = Perl_newSV (send - start);
+ register char *s = start;
+ UV uv;
+
+ while (s < send)
+ {
+ if (!(((UV)(uv)) < 0x80))
+ {
+ int hicount = 0;
+ unsigned char *c;
+ for (c = (unsigned char *)((XPV *)(sv)->sv_any)->xpv_pv;
+ c < (unsigned char *)d; c++)
+ {
+ if (!(((UV)(*c)) < 0x80))
+ {
+ hicount++;
+ }
+ }
+ d += hicount;
+ *d++ = (char)uv;
+ }
+
+ s++;
+ }
+
+ return s;
+}