aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorHao Liu <hliu@os.amperecomputing.com>2023-08-04 10:32:52 +0800
committerHao Liu <hliu@os.amperecomputing.com>2023-08-04 10:34:32 +0800
commit4d8b5563179f3a7ca268b64f71731a4878635497 (patch)
treeb53bc9512e0e4d75ef934595473f88e93af7c2d4
parent51e5a5cefb11d8a7b2216e866abcc225ba16d127 (diff)
downloadgcc-4d8b5563179f3a7ca268b64f71731a4878635497.zip
gcc-4d8b5563179f3a7ca268b64f71731a4878635497.tar.gz
gcc-4d8b5563179f3a7ca268b64f71731a4878635497.tar.bz2
AArch64: Avoid the ICE on empty reduction definition in info_for_reduction [PR110625]
Fix the assertion failure on empty reduction define in info_for_reduction. Even a stmt is live, it may still have empty reduction define. Check the reduction definition instead of live info before calling info_for_reduction. gcc/ChangeLog: PR target/110625 * config/aarch64/aarch64.cc (aarch64_force_single_cycle): check STMT_VINFO_REDUC_DEF to avoid failures in info_for_reduction. gcc/testsuite/ChangeLog: * gcc.target/aarch64/pr110625_3.c: New testcase.
-rw-r--r--gcc/config/aarch64/aarch64.cc2
-rw-r--r--gcc/testsuite/gcc.target/aarch64/pr110625_3.c35
2 files changed, 36 insertions, 1 deletions
diff --git a/gcc/config/aarch64/aarch64.cc b/gcc/config/aarch64/aarch64.cc
index d4d7602..5b8d8fa 100644
--- a/gcc/config/aarch64/aarch64.cc
+++ b/gcc/config/aarch64/aarch64.cc
@@ -16776,7 +16776,7 @@ aarch64_adjust_stmt_cost (vect_cost_for_stmt kind, stmt_vec_info stmt_info,
static bool
aarch64_force_single_cycle (vec_info *vinfo, stmt_vec_info stmt_info)
{
- if (!STMT_VINFO_LIVE_P (stmt_info))
+ if (!STMT_VINFO_REDUC_DEF (stmt_info))
return false;
auto reduc_info = info_for_reduction (vinfo, stmt_info);
diff --git a/gcc/testsuite/gcc.target/aarch64/pr110625_3.c b/gcc/testsuite/gcc.target/aarch64/pr110625_3.c
new file mode 100644
index 0000000..cdc2465
--- /dev/null
+++ b/gcc/testsuite/gcc.target/aarch64/pr110625_3.c
@@ -0,0 +1,35 @@
+/* { dg-do compile } */
+/* { dg-options "-O3 -mcpu=neoverse-n2" } */
+
+/* Avoid ICE on empty reduction def in info_for_reduction called by
+ aarch64_force_single_cycle.
+
+ E.g.
+ <bb 3> [local count: 858993456]:
+ # sum_18 = PHI <sum_15(5), 0(2)>
+ sum.0_5 = (unsigned int) sum_18;
+ _6 = _4 + sum.0_5; <-- it is "live" but doesn't have reduction def
+ sum_15 = (int) _6;
+ ...
+ if (ivtmp_29 != 0)
+ goto <bb 5>; [75.00%]
+ else
+ goto <bb 4>; [25.00%]
+
+ <bb 5> [local count: 644245086]:
+ goto <bb 3>; [100.00%]
+
+ <bb 4> [local count: 214748368]:
+ # _31 = PHI <_6(3)>
+ _8 = _31 >> 1;
+*/
+
+int
+f (unsigned int *tmp)
+{
+ int sum = 0;
+ for (int i = 0; i < 4; i++)
+ sum += tmp[i];
+
+ return (unsigned int) sum >> 1;
+}