From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mx2.suse.de (mx2.suse.de [195.135.220.15]) by sourceware.org (Postfix) with ESMTPS id 87C5B3858026 for ; Fri, 15 Jan 2021 10:27:36 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.3.2 sourceware.org 87C5B3858026 Authentication-Results: sourceware.org; dmarc=none (p=none dis=none) header.from=suse.de Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=rguenther@suse.de X-Virus-Scanned: by amavisd-new at test-mx.suse.de Received: from relay2.suse.de (unknown [195.135.221.27]) by mx2.suse.de (Postfix) with ESMTP id 6887EB80B for ; Fri, 15 Jan 2021 10:27:35 +0000 (UTC) Date: Fri, 15 Jan 2021 11:27:34 +0100 (CET) From: Richard Biener Sender: rguenther@ryzen.fritz.box To: gcc-patches@gcc.gnu.org Subject: [PATCH] tree-optimization/98685 - fix placement of extern converts Message-ID: User-Agent: Alpine 2.21 (LSU 202 2017-01-01) MIME-Version: 1.0 Content-Type: text/plain; charset=US-ASCII X-Spam-Status: No, score=-11.5 required=5.0 tests=BAYES_00, GIT_PATCH_0, KAM_DMARC_STATUS, RCVD_IN_MSPIKE_H3, RCVD_IN_MSPIKE_WL, SPF_HELO_NONE, SPF_PASS, TXREP autolearn=ham autolearn_force=no version=3.4.2 X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) 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: Fri, 15 Jan 2021 10:27:37 -0000 Avoid advancing to the next stmt when inserting at region boundary and deal with a vector def being not the only child. Bootstrapped and tested on x86_64-unknown-linux-gnu, pushed. 2021-01-15 Richard Biener PR tree-optimization/98685 * tree-vect-slp.c (vect_schedule_slp_node): Refactor handling of vector extern defs. * gcc.dg/vect/bb-slp-pr98685.c: New testcase. --- gcc/testsuite/gcc.dg/vect/bb-slp-pr98685.c | 15 +++++++++++++++ gcc/tree-vect-slp.c | 11 ++++++++--- 2 files changed, 23 insertions(+), 3 deletions(-) create mode 100644 gcc/testsuite/gcc.dg/vect/bb-slp-pr98685.c diff --git a/gcc/testsuite/gcc.dg/vect/bb-slp-pr98685.c b/gcc/testsuite/gcc.dg/vect/bb-slp-pr98685.c new file mode 100644 index 00000000000..b213335da78 --- /dev/null +++ b/gcc/testsuite/gcc.dg/vect/bb-slp-pr98685.c @@ -0,0 +1,15 @@ +/* { dg-do compile } */ +/* { dg-additional-options "-O3" } */ + +char onelock_lock[16]; +void write(void); + +void lockit(int count) { + for (; count;) { + int pid, i; + char *p; + for (i = 0, p = (char *)&pid; i < sizeof 0; i++) + onelock_lock[i] = *p++; + write(); + } +} diff --git a/gcc/tree-vect-slp.c b/gcc/tree-vect-slp.c index 6b6c9ccc0a0..1787ad74268 100644 --- a/gcc/tree-vect-slp.c +++ b/gcc/tree-vect-slp.c @@ -5915,6 +5915,7 @@ vect_schedule_slp_node (vec_info *vinfo, /* Emit other stmts after the children vectorized defs which is earliest possible. */ gimple *last_stmt = NULL; + bool seen_vector_def = false; FOR_EACH_VEC_ELT (SLP_TREE_CHILDREN (node), i, child) if (SLP_TREE_DEF_TYPE (child) == vect_internal_def) { @@ -5966,8 +5967,7 @@ vect_schedule_slp_node (vec_info *vinfo, we do not insert before the region boundary. */ if (SLP_TREE_SCALAR_OPS (child).is_empty () && !vinfo->lookup_def (SLP_TREE_VEC_DEFS (child)[0])) - last_stmt = gsi_stmt (gsi_after_labels - (as_a (vinfo)->bbs[0])); + seen_vector_def = true; else { unsigned j; @@ -5987,7 +5987,12 @@ vect_schedule_slp_node (vec_info *vinfo, constants. */ if (!last_stmt) last_stmt = vect_find_first_scalar_stmt_in_slp (node)->stmt; - if (is_a (last_stmt)) + if (!last_stmt) + { + gcc_assert (seen_vector_def); + si = gsi_after_labels (as_a (vinfo)->bbs[0]); + } + else if (is_a (last_stmt)) si = gsi_after_labels (gimple_bb (last_stmt)); else { -- 2.26.2