From: Richard Biener <rguenther@suse.de>
To: gcc-patches@gcc.gnu.org
Subject: [PATCH] Generic vector op costing adjustment
Date: Tue, 23 May 2023 17:15:48 +0200 (CEST) [thread overview]
Message-ID: <20230523151548.622FF13A10@imap2.suse-dmz.suse.de> (raw)
This is a small adjustment to the work done for PR108752 and
better reflects the cost of the generated sequence.
Bootstrapped and tested on x86_64-unknown-linux-gnu, pushed.
PR tree-optimization/108752
* tree-vect-stmts.cc (vectorizable_operation): For bit
operations with generic word_mode vectors do not cost
an extra stmt. For plus, minus and negate also cost the
constant materialization.
---
gcc/tree-vect-stmts.cc | 19 +++++++++++++++----
1 file changed, 15 insertions(+), 4 deletions(-)
diff --git a/gcc/tree-vect-stmts.cc b/gcc/tree-vect-stmts.cc
index 0022b878767..127b987cd62 100644
--- a/gcc/tree-vect-stmts.cc
+++ b/gcc/tree-vect-stmts.cc
@@ -6466,8 +6466,8 @@ vectorizable_operation (vec_info *vinfo,
{
/* The above vect_model_simple_cost call handles constants
in the prologue and (mis-)costs one of the stmts as
- vector stmt. See tree-vect-generic.cc:do_plus_minus/do_negate
- for the actual lowering that will be applied. */
+ vector stmt. See below for the actual lowering that will
+ be applied. */
unsigned n
= slp_node ? SLP_TREE_NUMBER_OF_VEC_STMTS (slp_node) : ncopies;
switch (code)
@@ -6481,9 +6481,20 @@ vectorizable_operation (vec_info *vinfo,
case NEGATE_EXPR:
n *= 4;
break;
- default:;
+ default:
+ /* Bit operations do not have extra cost and are accounted
+ as vector stmt by vect_model_simple_cost. */
+ n = 0;
+ break;
+ }
+ if (n != 0)
+ {
+ /* We also need to materialize two large constants. */
+ record_stmt_cost (cost_vec, 2, scalar_stmt, stmt_info,
+ 0, vect_prologue);
+ record_stmt_cost (cost_vec, n, scalar_stmt, stmt_info,
+ 0, vect_body);
}
- record_stmt_cost (cost_vec, n, scalar_stmt, stmt_info, 0, vect_body);
}
return true;
}
--
2.35.3
reply other threads:[~2023-05-23 15:15 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=20230523151548.622FF13A10@imap2.suse-dmz.suse.de \
--to=rguenther@suse.de \
--cc=gcc-patches@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: link
Be 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).