]> git.ipfire.org Git - thirdparty/gcc.git/commitdiff
AArch64: Avoid the ICE on empty reduction definition in info_for_reduction [PR110625]
authorHao Liu <hliu@os.amperecomputing.com>
Fri, 4 Aug 2023 02:32:52 +0000 (10:32 +0800)
committerHao Liu <hliu@os.amperecomputing.com>
Fri, 4 Aug 2023 02:34:32 +0000 (10:34 +0800)
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.

gcc/config/aarch64/aarch64.cc
gcc/testsuite/gcc.target/aarch64/pr110625_3.c [new file with mode: 0644]

index d4d7602554592b9042b8eaf389eff1ec80c2090e..5b8d8fa8e2d6977424e52bdcabc6aeb116f294a6 100644 (file)
@@ -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 (file)
index 0000000..cdc2465
--- /dev/null
@@ -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;
+}