From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 1666) id EE3C73858CD1; Tue, 12 Mar 2024 07:17:24 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org EE3C73858CD1 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gcc.gnu.org; s=default; t=1710227844; bh=JB7QAW63Z/S93E1oXr8rdz/GkL5Hbf6DO+NOZ2NSnEw=; h=From:To:Subject:Date:From; b=njQSYFKTXAYCrkXce5vzqttka5IFP+bG21jxs1GWJx7M2mkOIV0ZjlF4FEUVCtDtQ cCoOrC1kBxAAIljsJqk7B7XFn0zAyi9yjQAoGCn2sFZmGh7vVRyCt7pjly4kU0+YvE Gj4aci4nNBmQr6wvuMcQEb372iiyAmstrTsim7Lw= MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Content-Type: text/plain; charset="utf-8" From: Richard Biener To: gcc-cvs@gcc.gnu.org Subject: [gcc r14-9435] tree-optimization/114297 - SLP reduction with early break fix X-Act-Checkin: gcc X-Git-Author: Richard Biener X-Git-Refname: refs/heads/master X-Git-Oldrev: c4e5789cede6974b6483c0f82069ff80b5a547e4 X-Git-Newrev: c0c57246d5b47459bdb488734bc2c004a92668b5 Message-Id: <20240312071724.EE3C73858CD1@sourceware.org> Date: Tue, 12 Mar 2024 07:17:24 +0000 (GMT) List-Id: https://gcc.gnu.org/g:c0c57246d5b47459bdb488734bc2c004a92668b5 commit r14-9435-gc0c57246d5b47459bdb488734bc2c004a92668b5 Author: Richard Biener Date: Mon Mar 11 14:58:57 2024 +0100 tree-optimization/114297 - SLP reduction with early break fix The following makes sure to pass in the SLP node for the live stmts we are generating the reduction epilogue for to vect_create_epilog_for_reduction. This follows the previous fix for the non-SLP path. PR tree-optimization/114297 * tree-vect-loop.cc (vectorizable_live_operation): Pass in the live stmts SLP node to vect_create_epilog_for_reduction. * gcc.dg/vect/vect-early-break_123-pr114297.c: New testcase. Diff: --- .../gcc.dg/vect/vect-early-break_123-pr114297.c | 22 ++++++++++++++++++++++ gcc/tree-vect-loop.cc | 7 ++++--- 2 files changed, 26 insertions(+), 3 deletions(-) diff --git a/gcc/testsuite/gcc.dg/vect/vect-early-break_123-pr114297.c b/gcc/testsuite/gcc.dg/vect/vect-early-break_123-pr114297.c new file mode 100644 index 00000000000..84487b7903b --- /dev/null +++ b/gcc/testsuite/gcc.dg/vect/vect-early-break_123-pr114297.c @@ -0,0 +1,22 @@ +/* { dg-do compile } */ +/* { dg-add-options vect_early_break } */ +/* { dg-require-effective-target vect_early_break } */ + +void h() __attribute__((__noreturn__)); +struct Extremes { + int w; + int h; +}; +struct Extremes *array; +int f(int num, int size1) +{ + int sw = 0, sh = 0; + for (int i = 0; i < size1; ++i) + { + if (num - i == 0) + h(); + sw += array[i].w; + sh += array[i].h; + } + return (sw) + (sh); +} diff --git a/gcc/tree-vect-loop.cc b/gcc/tree-vect-loop.cc index 20ee0aad932..4375ebdcb49 100644 --- a/gcc/tree-vect-loop.cc +++ b/gcc/tree-vect-loop.cc @@ -10729,17 +10729,18 @@ vectorizable_live_operation (vec_info *vinfo, stmt_vec_info stmt_info, block, but we have to find an alternate exit first. */ if (LOOP_VINFO_EARLY_BREAKS (loop_vinfo)) { + slp_tree phis_node = slp_node ? slp_node_instance->reduc_phis : NULL; for (auto exit : get_loop_exit_edges (LOOP_VINFO_LOOP (loop_vinfo))) if (exit != LOOP_VINFO_IV_EXIT (loop_vinfo)) { vect_create_epilog_for_reduction (loop_vinfo, reduc_info, - slp_node, slp_node_instance, + phis_node, slp_node_instance, exit); break; } if (LOOP_VINFO_EARLY_BREAKS_VECT_PEELED (loop_vinfo)) - vect_create_epilog_for_reduction (loop_vinfo, reduc_info, slp_node, - slp_node_instance, + vect_create_epilog_for_reduction (loop_vinfo, reduc_info, + phis_node, slp_node_instance, LOOP_VINFO_IV_EXIT (loop_vinfo)); }