From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from smtp-out1.suse.de (smtp-out1.suse.de [195.135.220.28]) by sourceware.org (Postfix) with ESMTPS id 2E2B9388E818 for ; Tue, 29 Jun 2021 08:34:53 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.1 sourceware.org 2E2B9388E818 Authentication-Results: sourceware.org; dmarc=none (p=none dis=none) header.from=suse.de Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=suse.de Received: from relay2.suse.de (relay2.suse.de [149.44.160.134]) by smtp-out1.suse.de (Postfix) with ESMTP id CEBFD2262D for ; Tue, 29 Jun 2021 08:34:51 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_rsa; t=1624955691; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc: mime-version:mime-version:content-type:content-type; bh=+FB49tDagRIHajFIBt4d4zJV3i3ecWCgyk7Q+b75Og0=; b=ULRgGiEF9gJcZNaScgcP+v2fgjbCC8K/j7kJLGNFgo3SUjQuZUYtYKp0iPvBsW2yayUfyZ N2nSGA5TXnxxAUyGxyCBleiwChR4p8YtZzSNa6RSJ6SD2xCqlbbw4K1gZ8ddwcDlDwpKp3 YgMk3cYchCbNBQkUGmxK+nhCQMjGDMw= DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_ed25519; t=1624955691; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc: mime-version:mime-version:content-type:content-type; bh=+FB49tDagRIHajFIBt4d4zJV3i3ecWCgyk7Q+b75Og0=; b=Rk5F9N90fn/ikZWwt7PVmfkB3Dixe8VIhGmQimrWPtBdGWsu3FGd/GVQ64SLwT+2WlFvvN UwG9ZgTAiJJHlhCQ== Received: from [10.163.41.62] (unknown [10.163.41.62]) (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 BCA45A3B88 for ; Tue, 29 Jun 2021 08:34:51 +0000 (UTC) Date: Tue, 29 Jun 2021 10:34:51 +0200 (CEST) From: Richard Biener To: gcc-patches@gcc.gnu.org Subject: [PATCH] tree-optimization/101242 - fix reverse graph entry detection Message-ID: MIME-Version: 1.0 Content-Type: text/plain; charset=US-ASCII X-Spam-Status: No, score=-10.7 required=5.0 tests=BAYES_00, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, DKIM_VALID_EF, GIT_PATCH_0, 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: Tue, 29 Jun 2021 08:34:54 -0000 This avoids detecting random unrelated nodes as possible entries to not backwards reachable regions of the SLP graph. Instead explicitely add the problematic nodes. This temporary XFAILs gcc.dg/vect/pr67790.c until I get the permute propagation adjusted to when it needs more than one optimistic iteration. Bootstrapped and tested on x86_64-unknown-linux-gnu, pushed. 2021-06-29 Richard Biener PR tree-optimization/101242 * tree-vect-slp.c (vect_slp_build_vertices): Force-add PHIs with not represented initial values as leafs. * gcc.dg/vect/bb-slp-pr101242.c: New testcase. * gcc.dg/vect/pr67790.c: XFAIL scan for zero VEC_PERM_EXPR. --- gcc/testsuite/gcc.dg/vect/bb-slp-pr101242.c | 38 +++++++++++++++++++++ gcc/testsuite/gcc.dg/vect/pr67790.c | 2 +- gcc/tree-vect-slp.c | 24 ++++++------- 3 files changed, 50 insertions(+), 14 deletions(-) create mode 100644 gcc/testsuite/gcc.dg/vect/bb-slp-pr101242.c diff --git a/gcc/testsuite/gcc.dg/vect/bb-slp-pr101242.c b/gcc/testsuite/gcc.dg/vect/bb-slp-pr101242.c new file mode 100644 index 00000000000..d8854468df4 --- /dev/null +++ b/gcc/testsuite/gcc.dg/vect/bb-slp-pr101242.c @@ -0,0 +1,38 @@ +/* { dg-do compile } */ +/* { dg-additional-options "-Ofast" } */ + +typedef struct { + double real; + double imag; +} complex; +typedef struct { + complex e[3][3]; +} su3_matrix; +su3_matrix check_su3_c; +double check_su3_ar, check_su3_ari, check_su3_max; +int arireturn(); +int check_su3() { + check_su3_ar = check_su3_c.e[0][0].real * check_su3_c.e[1][0].real + + check_su3_c.e[0][0].imag * check_su3_c.e[1][0].imag + + check_su3_c.e[0][1].real * check_su3_c.e[1][1].real + + check_su3_c.e[0][1].imag * check_su3_c.e[1][1].imag + + check_su3_c.e[0][2].real * check_su3_c.e[1][2].real + + check_su3_c.e[0][2].imag * check_su3_c.e[1][2].imag; + check_su3_max = check_su3_c.e[0][0].real * check_su3_c.e[2][0].real + + check_su3_c.e[0][0].imag * check_su3_c.e[2][0].imag + + check_su3_c.e[0][1].real * check_su3_c.e[2][1].real + + check_su3_c.e[0][1].imag * check_su3_c.e[2][1].imag + + check_su3_c.e[0][2].real * check_su3_c.e[2][2].real + + check_su3_c.e[0][2].imag * check_su3_c.e[2][2].imag; + check_su3_ari = check_su3_ar; + if (check_su3_ari) + check_su3_max = check_su3_c.e[1][0].real * check_su3_c.e[2][0].real + + check_su3_c.e[1][0].imag * check_su3_c.e[2][0].imag + + check_su3_c.e[1][1].real * check_su3_c.e[2][1].real + + check_su3_c.e[1][1].imag * check_su3_c.e[2][1].imag + + check_su3_c.e[1][2].real * check_su3_c.e[2][2].real + + check_su3_c.e[1][2].imag * check_su3_c.e[2][2].imag; + if (check_su3_max) + arireturn(); + return 0; +} diff --git a/gcc/testsuite/gcc.dg/vect/pr67790.c b/gcc/testsuite/gcc.dg/vect/pr67790.c index 32eacd91fda..0555d41abf7 100644 --- a/gcc/testsuite/gcc.dg/vect/pr67790.c +++ b/gcc/testsuite/gcc.dg/vect/pr67790.c @@ -38,4 +38,4 @@ int main() } /* { dg-final { scan-tree-dump "vectorizing stmts using SLP" "vect" } } */ -/* { dg-final { scan-tree-dump-times "VEC_PERM_EXPR" 0 "vect" } } */ +/* { dg-final { scan-tree-dump-times "VEC_PERM_EXPR" 0 "vect" { xfail *-*-* } } } */ diff --git a/gcc/tree-vect-slp.c b/gcc/tree-vect-slp.c index 5401dbe4d5e..63b6e6a24b9 100644 --- a/gcc/tree-vect-slp.c +++ b/gcc/tree-vect-slp.c @@ -3499,13 +3499,21 @@ vect_slp_build_vertices (hash_set &visited, slp_tree node, vertices.safe_push (slpg_vertex (node)); bool leaf = true; + bool force_leaf = false; FOR_EACH_VEC_ELT (SLP_TREE_CHILDREN (node), i, child) if (child) { leaf = false; vect_slp_build_vertices (visited, child, vertices, leafs); } - if (leaf) + else + force_leaf = true; + /* Since SLP discovery works along use-def edges all cycles have an + entry - but there's the exception of cycles where we do not handle + the entry explicitely (but with a NULL SLP node), like some reductions + and inductions. Force those SLP PHIs to act as leafs to make them + backwards reachable. */ + if (leaf || force_leaf) leafs.safe_push (node->vertex); } @@ -3519,18 +3527,8 @@ vect_slp_build_vertices (vec_info *info, vec &vertices, unsigned i; slp_instance instance; FOR_EACH_VEC_ELT (info->slp_instances, i, instance) - { - unsigned n_v = vertices.length (); - unsigned n_l = leafs.length (); - vect_slp_build_vertices (visited, SLP_INSTANCE_TREE (instance), vertices, - leafs); - /* If we added vertices but no entries to the reverse graph we've - added a cycle that is not backwards-reachable. Push the entry - to mimic as leaf then. */ - if (vertices.length () > n_v - && leafs.length () == n_l) - leafs.safe_push (SLP_INSTANCE_TREE (instance)->vertex); - } + vect_slp_build_vertices (visited, SLP_INSTANCE_TREE (instance), vertices, + leafs); } /* Apply (reverse) bijectite PERM to VEC. */ -- 2.26.2