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 r12-2727] tree-optimization/101756 - avoid vectorizing boolean MAX reductions Date: Wed, 4 Aug 2021 10:33:31 +0000 (GMT) [thread overview] Message-ID: <20210804103331.B573C3972838@sourceware.org> (raw) https://gcc.gnu.org/g:87a0b607e40f8122c7fc45d496ef48799fe11550 commit r12-2727-g87a0b607e40f8122c7fc45d496ef48799fe11550 Author: Richard Biener <rguenther@suse.de> Date: Wed Aug 4 11:42:41 2021 +0200 tree-optimization/101756 - avoid vectorizing boolean MAX reductions The following avoids vectorizing MIN/MAX reductions on bools which, when ending up as vector(2) <signed-boolean:64> would need to be adjusted because of the sign change. The fix instead avoids any reduction vectorization where the result isn't compatible to the original scalar type since we don't compensate for that either. 2021-08-04 Richard Biener <rguenther@suse.de> PR tree-optimization/101756 * tree-vect-slp.c (vectorizable_bb_reduc_epilogue): Make sure the result of the reduction epilogue is compatible to the original scalar result. * gcc.dg/vect/bb-slp-pr101756.c: New testcase. Diff: --- gcc/testsuite/gcc.dg/vect/bb-slp-pr101756.c | 15 +++++++++++++++ gcc/tree-vect-slp.c | 8 +++++--- 2 files changed, 20 insertions(+), 3 deletions(-) diff --git a/gcc/testsuite/gcc.dg/vect/bb-slp-pr101756.c b/gcc/testsuite/gcc.dg/vect/bb-slp-pr101756.c new file mode 100644 index 00000000000..9420e77f64e --- /dev/null +++ b/gcc/testsuite/gcc.dg/vect/bb-slp-pr101756.c @@ -0,0 +1,15 @@ +/* { dg-do compile } */ + +__attribute__ ((simd)) int +tq (long int ea, int of, int kk) +{ + int bc; + + for (bc = 0; bc < 2; ++bc) + { + ++ea; + of |= !!kk < !!ea; + } + + return of; +} diff --git a/gcc/tree-vect-slp.c b/gcc/tree-vect-slp.c index a554c24e0fb..d169bed8e94 100644 --- a/gcc/tree-vect-slp.c +++ b/gcc/tree-vect-slp.c @@ -4847,15 +4847,17 @@ static bool vectorizable_bb_reduc_epilogue (slp_instance instance, stmt_vector_for_cost *cost_vec) { - enum tree_code reduc_code - = gimple_assign_rhs_code (instance->root_stmts[0]->stmt); + gassign *stmt = as_a <gassign *> (instance->root_stmts[0]->stmt); + enum tree_code reduc_code = gimple_assign_rhs_code (stmt); if (reduc_code == MINUS_EXPR) reduc_code = PLUS_EXPR; internal_fn reduc_fn; tree vectype = SLP_TREE_VECTYPE (SLP_INSTANCE_TREE (instance)); if (!reduction_fn_for_scalar_code (reduc_code, &reduc_fn) || reduc_fn == IFN_LAST - || !direct_internal_fn_supported_p (reduc_fn, vectype, OPTIMIZE_FOR_BOTH)) + || !direct_internal_fn_supported_p (reduc_fn, vectype, OPTIMIZE_FOR_BOTH) + || !useless_type_conversion_p (TREE_TYPE (gimple_assign_lhs (stmt)), + TREE_TYPE (vectype))) return false; /* There's no way to cost a horizontal vector reduction via REDUC_FN so
reply other threads:[~2021-08-04 10:33 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=20210804103331.B573C3972838@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).