From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from smtp-out2.suse.de (smtp-out2.suse.de [195.135.220.29]) by sourceware.org (Postfix) with ESMTPS id 25CD2385828E for ; Tue, 5 Jul 2022 09:02:38 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.1 sourceware.org 25CD2385828E Received: from relay2.suse.de (relay2.suse.de [149.44.160.134]) by smtp-out2.suse.de (Postfix) with ESMTP id E71A8200CE for ; Tue, 5 Jul 2022 09:02:36 +0000 (UTC) Received: from wotan.suse.de (wotan.suse.de [10.160.0.1]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by relay2.suse.de (Postfix) with ESMTPS id DF82B2C141 for ; Tue, 5 Jul 2022 09:02:36 +0000 (UTC) Date: Tue, 5 Jul 2022 09:02:36 +0000 (UTC) From: Richard Biener To: gcc-patches@gcc.gnu.org Subject: [PATCH] tree-optimization/106196 - properly update virtual SSA for vector stores User-Agent: Alpine 2.22 (LSU 394 2020-01-19) MIME-Version: 1.0 Content-Type: text/plain; charset=US-ASCII X-Spam-Status: No, score=-10.5 required=5.0 tests=BAYES_00, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, DKIM_VALID_EF, GIT_PATCH_0, MISSING_MID, SPF_HELO_NONE, SPF_PASS, TXREP, T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on server2.sourceware.org X-BeenThere: gcc-patches@gcc.gnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Gcc-patches mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 05 Jul 2022 09:02:39 -0000 Message-ID: <20220705090236.oeYsNyOHW3Eg-Zc-gV7ptp1FqUSJfzjqggsHPAAfs3o@z> The following properly handles aggregate returns of the const marked STORE_LANES internal function to update virtual SSA form on-the-fly rather than relying on a costly virtual SSA rewrite. Bootstrap and regtest running on x86_64-unknown-linux-gnu. PR tree-optimization/106196 * tree-vect-stmts.cc (vect_finish_stmt_generation): Properly handle aggregate returns of calls for VDEF updates. * gcc.dg/torture/pr106196.c: New testcase. --- gcc/testsuite/gcc.dg/torture/pr106196.c | 14 ++++++++++++++ gcc/tree-vect-stmts.cc | 6 ++++-- 2 files changed, 18 insertions(+), 2 deletions(-) create mode 100644 gcc/testsuite/gcc.dg/torture/pr106196.c diff --git a/gcc/testsuite/gcc.dg/torture/pr106196.c b/gcc/testsuite/gcc.dg/torture/pr106196.c new file mode 100644 index 00000000000..56723de42c2 --- /dev/null +++ b/gcc/testsuite/gcc.dg/torture/pr106196.c @@ -0,0 +1,14 @@ +/* { dg-do compile } */ +/* { dg-additional-options "-ftree-vectorize -fno-vect-cost-model" } */ + +extern char a[]; +char *b; +void e() { + char *d; + int c; + d = a; + for (; c; c++) { + d[2] = d[1] = d[0] = b[c]; + d += 3; + } +} diff --git a/gcc/tree-vect-stmts.cc b/gcc/tree-vect-stmts.cc index 72107afc883..3db6620dd42 100644 --- a/gcc/tree-vect-stmts.cc +++ b/gcc/tree-vect-stmts.cc @@ -1638,8 +1638,10 @@ vect_finish_stmt_generation (vec_info *vinfo, && ((is_gimple_assign (vec_stmt) && !is_gimple_reg (gimple_assign_lhs (vec_stmt))) || (is_gimple_call (vec_stmt) - && !(gimple_call_flags (vec_stmt) - & (ECF_CONST|ECF_PURE|ECF_NOVOPS))))) + && (!(gimple_call_flags (vec_stmt) + & (ECF_CONST|ECF_PURE|ECF_NOVOPS)) + || (gimple_call_lhs (vec_stmt) + && !is_gimple_reg (gimple_call_lhs (vec_stmt))))))) { tree new_vdef = copy_ssa_name (vuse, vec_stmt); gimple_set_vdef (vec_stmt, new_vdef); -- 2.35.3