From: Hao Liu Date: Fri, 4 Aug 2023 02:32:52 +0000 (+0800) Subject: AArch64: Avoid the ICE on empty reduction definition in info_for_reduction [PR110625] X-Git-Tag: basepoints/gcc-15~7166 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=4d8b5563179f3a7ca268b64f71731a4878635497;p=thirdparty%2Fgcc.git 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. --- diff --git a/gcc/config/aarch64/aarch64.cc b/gcc/config/aarch64/aarch64.cc index d4d760255459..5b8d8fa8e2d6 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 000000000000..cdc2465b04bd --- /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. + [local count: 858993456]: + # sum_18 = PHI + 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 ; [75.00%] + else + goto ; [25.00%] + + [local count: 644245086]: + goto ; [100.00%] + + [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; +}