public inbox for gcc-cvs@sourceware.org help / color / mirror / Atom feed
From: Richard Biener <rguenth@gcc.gnu.org> To: gcc-cvs@gcc.gnu.org Subject: [gcc r14-4682] tree-optimization/111846 - put simd-clone-info into SLP tree Date: Tue, 17 Oct 2023 12:27:46 +0000 (GMT) [thread overview] Message-ID: <20231017122746.82C50385CC87@sourceware.org> (raw) https://gcc.gnu.org/g:323209cd73bf1d81d91637677db5883afc8ae5f6 commit r14-4682-g323209cd73bf1d81d91637677db5883afc8ae5f6 Author: Richard Biener <rguenther@suse.de> Date: Tue Oct 17 13:42:59 2023 +0200 tree-optimization/111846 - put simd-clone-info into SLP tree The following avoids bogously re-using the simd-clone-info we currently hang off stmt_info from two different SLP contexts where a different number of lanes should have chosen a different best simdclone. PR tree-optimization/111846 * tree-vectorizer.h (_slp_tree::simd_clone_info): Add. (SLP_TREE_SIMD_CLONE_INFO): New. * tree-vect-slp.cc (_slp_tree::_slp_tree): Initialize SLP_TREE_SIMD_CLONE_INFO. (_slp_tree::~_slp_tree): Release it. * tree-vect-stmts.cc (vectorizable_simd_clone_call): Use SLP_TREE_SIMD_CLONE_INFO or STMT_VINFO_SIMD_CLONE_INFO dependent on if we're doing SLP. * gcc.dg/vect/pr111846.c: New testcase. Diff: --- gcc/testsuite/gcc.dg/vect/pr111846.c | 12 ++++++++++++ gcc/tree-vect-slp.cc | 2 ++ gcc/tree-vect-stmts.cc | 35 ++++++++++++++++------------------- gcc/tree-vectorizer.h | 6 ++++++ 4 files changed, 36 insertions(+), 19 deletions(-) diff --git a/gcc/testsuite/gcc.dg/vect/pr111846.c b/gcc/testsuite/gcc.dg/vect/pr111846.c new file mode 100644 index 000000000000..d283882f2614 --- /dev/null +++ b/gcc/testsuite/gcc.dg/vect/pr111846.c @@ -0,0 +1,12 @@ +/* { dg-do compile } */ +/* { dg-options "-O3 -ffast-math" } */ +/* { dg-additional-options "-mavx2" { target { x86_64-*-* i?86-*-* } } } */ + +extern __attribute__((__simd__)) float powf(float, float); +float gv[0][10]; +float eq_set_bands_real_adj[0]; +void eq_set_bands_real() { + for (int c = 0; c < 10; c++) + for (int i = 0; i < 10; i++) + gv[c][i] = powf(0, eq_set_bands_real_adj[i]) - 1; +} diff --git a/gcc/tree-vect-slp.cc b/gcc/tree-vect-slp.cc index af8f5031bd27..d081999a763c 100644 --- a/gcc/tree-vect-slp.cc +++ b/gcc/tree-vect-slp.cc @@ -117,6 +117,7 @@ _slp_tree::_slp_tree () SLP_TREE_CHILDREN (this) = vNULL; SLP_TREE_LOAD_PERMUTATION (this) = vNULL; SLP_TREE_LANE_PERMUTATION (this) = vNULL; + SLP_TREE_SIMD_CLONE_INFO (this) = vNULL; SLP_TREE_DEF_TYPE (this) = vect_uninitialized_def; SLP_TREE_CODE (this) = ERROR_MARK; SLP_TREE_VECTYPE (this) = NULL_TREE; @@ -143,6 +144,7 @@ _slp_tree::~_slp_tree () SLP_TREE_VEC_DEFS (this).release (); SLP_TREE_LOAD_PERMUTATION (this).release (); SLP_TREE_LANE_PERMUTATION (this).release (); + SLP_TREE_SIMD_CLONE_INFO (this).release (); if (this->failed) free (failed); } diff --git a/gcc/tree-vect-stmts.cc b/gcc/tree-vect-stmts.cc index b3a56498595d..9bb43e98f56d 100644 --- a/gcc/tree-vect-stmts.cc +++ b/gcc/tree-vect-stmts.cc @@ -4215,6 +4215,8 @@ vectorizable_simd_clone_call (vec_info *vinfo, stmt_vec_info stmt_info, if (nargs == 0) return false; + vec<tree>& simd_clone_info = (slp_node ? SLP_TREE_SIMD_CLONE_INFO (slp_node) + : STMT_VINFO_SIMD_CLONE_INFO (stmt_info)); arginfo.reserve (nargs, true); auto_vec<slp_tree> slp_op; slp_op.safe_grow_cleared (nargs); @@ -4256,25 +4258,22 @@ vectorizable_simd_clone_call (vec_info *vinfo, stmt_vec_info stmt_info, gcc_assert (thisarginfo.vectype != NULL_TREE); /* For linear arguments, the analyze phase should have saved - the base and step in STMT_VINFO_SIMD_CLONE_INFO. */ - if (i * 3 + 4 <= STMT_VINFO_SIMD_CLONE_INFO (stmt_info).length () - && STMT_VINFO_SIMD_CLONE_INFO (stmt_info)[i * 3 + 2]) + the base and step in {STMT_VINFO,SLP_TREE}_SIMD_CLONE_INFO. */ + if (i * 3 + 4 <= simd_clone_info.length () + && simd_clone_info[i * 3 + 2]) { gcc_assert (vec_stmt); - thisarginfo.linear_step - = tree_to_shwi (STMT_VINFO_SIMD_CLONE_INFO (stmt_info)[i * 3 + 2]); - thisarginfo.op - = STMT_VINFO_SIMD_CLONE_INFO (stmt_info)[i * 3 + 1]; + thisarginfo.linear_step = tree_to_shwi (simd_clone_info[i * 3 + 2]); + thisarginfo.op = simd_clone_info[i * 3 + 1]; thisarginfo.simd_lane_linear - = (STMT_VINFO_SIMD_CLONE_INFO (stmt_info)[i * 3 + 3] - == boolean_true_node); + = (simd_clone_info[i * 3 + 3] == boolean_true_node); /* If loop has been peeled for alignment, we need to adjust it. */ tree n1 = LOOP_VINFO_NITERS_UNCHANGED (loop_vinfo); tree n2 = LOOP_VINFO_NITERS (loop_vinfo); if (n1 != n2 && !thisarginfo.simd_lane_linear) { tree bias = fold_build2 (MINUS_EXPR, TREE_TYPE (n1), n1, n2); - tree step = STMT_VINFO_SIMD_CLONE_INFO (stmt_info)[i * 3 + 2]; + tree step = simd_clone_info[i * 3 + 2]; tree opt = TREE_TYPE (thisarginfo.op); bias = fold_convert (TREE_TYPE (step), bias); bias = fold_build2 (MULT_EXPR, TREE_TYPE (step), bias, step); @@ -4328,8 +4327,8 @@ vectorizable_simd_clone_call (vec_info *vinfo, stmt_vec_info stmt_info, unsigned group_size = slp_node ? SLP_TREE_LANES (slp_node) : 1; unsigned int badness = 0; struct cgraph_node *bestn = NULL; - if (STMT_VINFO_SIMD_CLONE_INFO (stmt_info).exists ()) - bestn = cgraph_node::get (STMT_VINFO_SIMD_CLONE_INFO (stmt_info)[0]); + if (simd_clone_info.exists ()) + bestn = cgraph_node::get (simd_clone_info[0]); else for (struct cgraph_node *n = node->simd_clones; n != NULL; n = n->simdclone->next_clone) @@ -4532,24 +4531,22 @@ vectorizable_simd_clone_call (vec_info *vinfo, stmt_vec_info stmt_info, so automagic virtual operand updating doesn't work. */ if (gimple_vuse (stmt) && slp_node) vinfo->any_known_not_updated_vssa = true; - STMT_VINFO_SIMD_CLONE_INFO (stmt_info).safe_push (bestn->decl); + simd_clone_info.safe_push (bestn->decl); for (i = 0; i < nargs; i++) if ((bestn->simdclone->args[i].arg_type == SIMD_CLONE_ARG_TYPE_LINEAR_CONSTANT_STEP) || (bestn->simdclone->args[i].arg_type == SIMD_CLONE_ARG_TYPE_LINEAR_REF_CONSTANT_STEP)) { - STMT_VINFO_SIMD_CLONE_INFO (stmt_info).safe_grow_cleared (i * 3 - + 1, - true); - STMT_VINFO_SIMD_CLONE_INFO (stmt_info).safe_push (arginfo[i].op); + simd_clone_info.safe_grow_cleared (i * 3 + 1, true); + simd_clone_info.safe_push (arginfo[i].op); tree lst = POINTER_TYPE_P (TREE_TYPE (arginfo[i].op)) ? size_type_node : TREE_TYPE (arginfo[i].op); tree ls = build_int_cst (lst, arginfo[i].linear_step); - STMT_VINFO_SIMD_CLONE_INFO (stmt_info).safe_push (ls); + simd_clone_info.safe_push (ls); tree sll = arginfo[i].simd_lane_linear ? boolean_true_node : boolean_false_node; - STMT_VINFO_SIMD_CLONE_INFO (stmt_info).safe_push (sll); + simd_clone_info.safe_push (sll); } STMT_VINFO_TYPE (stmt_info) = call_simd_clone_vec_info_type; DUMP_VECT_SCOPE ("vectorizable_simd_clone_call"); diff --git a/gcc/tree-vectorizer.h b/gcc/tree-vectorizer.h index f1d0cd79961a..f3152927e2d0 100644 --- a/gcc/tree-vectorizer.h +++ b/gcc/tree-vectorizer.h @@ -196,6 +196,11 @@ struct _slp_tree { denotes the number of output lanes. */ lane_permutation_t lane_permutation; + /* Selected SIMD clone's function info. First vector element + is SIMD clone's function decl, followed by a pair of trees (base + step) + for linear arguments (pair of NULLs for other arguments). */ + vec<tree> simd_clone_info; + tree vectype; /* Vectorized defs. */ vec<tree> vec_defs; @@ -300,6 +305,7 @@ public: #define SLP_TREE_NUMBER_OF_VEC_STMTS(S) (S)->vec_stmts_size #define SLP_TREE_LOAD_PERMUTATION(S) (S)->load_permutation #define SLP_TREE_LANE_PERMUTATION(S) (S)->lane_permutation +#define SLP_TREE_SIMD_CLONE_INFO(S) (S)->simd_clone_info #define SLP_TREE_DEF_TYPE(S) (S)->def_type #define SLP_TREE_VECTYPE(S) (S)->vectype #define SLP_TREE_REPRESENTATIVE(S) (S)->representative
reply other threads:[~2023-10-17 12:27 UTC|newest] Thread overview: [no followups] expand[flat|nested] mbox.gz Atom feed
Reply instructions: You may reply publicly to this message via plain-text email using any one of the following methods: * Save the following mbox file, import it into your mail client, and reply-to-all from there: mbox Avoid top-posting and favor interleaved quoting: https://en.wikipedia.org/wiki/Posting_style#Interleaved_style * Reply using the --to, --cc, and --in-reply-to switches of git-send-email(1): git send-email \ --in-reply-to=20231017122746.82C50385CC87@sourceware.org \ --to=rguenth@gcc.gnu.org \ --cc=gcc-cvs@gcc.gnu.org \ /path/to/YOUR_REPLY https://kernel.org/pub/software/scm/git/docs/git-send-email.html * If your mail client supports setting the In-Reply-To header via mailto: links, try the mailto: linkBe sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions for how to clone and mirror all data and code used for this inbox; as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).