aboutsummaryrefslogtreecommitdiff
path: root/gcc/targhooks.c
diff options
context:
space:
mode:
authorKewen Lin <linkw@linux.ibm.com>2021-05-19 05:42:51 -0500
committerKewen Lin <linkw@linux.ibm.com>2021-05-20 03:46:47 -0500
commit9c5bd1e9811babe255ddbbdcda1d00ea5997b826 (patch)
tree7d3ee49acadcfbc6c7a4cbb4c096f398db0538f7 /gcc/targhooks.c
parent1a9b3f04c11eb467a8dc504a37dad57a371a0d4c (diff)
downloadgcc-9c5bd1e9811babe255ddbbdcda1d00ea5997b826.zip
gcc-9c5bd1e9811babe255ddbbdcda1d00ea5997b826.tar.gz
gcc-9c5bd1e9811babe255ddbbdcda1d00ea5997b826.tar.bz2
vect: Replace hardcoded inner loop cost factor
This patch is to replace the current hardcoded weight factor 50, which is applied by the loop vectorizer to the cost of statements in an inner loop relative to the loop being vectorized, with one newly added member inner_loop_cost_factor in loop vinfo. It also introduces one parameter vect-inner-loop-cost-factor whose default value is 50, and is used to initialize the inner_loop_cost_factor member. The motivation here is that: if targets want to have one unique function to gather some information in each add_stmt_cost call, no matter that it's put before or after the cost tweaking part for inner loop, it may have the need to adjust (expand or shrink) the gathered data as the factor. Now the factor is hardcoded, it's not easily maintained. Bootstrapped/regtested on powerpc64le-linux-gnu P9, x86_64-redhat-linux and aarch64-linux-gnu. gcc/ChangeLog: * doc/invoke.texi (vect-inner-loop-cost-factor): Document new parameter. * params.opt (vect-inner-loop-cost-factor): New. * targhooks.c (default_add_stmt_cost): Replace hardcoded factor 50 with LOOP_VINFO_INNER_LOOP_COST_FACTOR, include head file tree-vectorizer.h and its required ones. * config/aarch64/aarch64.c (aarch64_add_stmt_cost): Replace hardcoded factor 50 with LOOP_VINFO_INNER_LOOP_COST_FACTOR. * config/arm/arm.c (arm_add_stmt_cost): Likewise. * config/i386/i386.c (ix86_add_stmt_cost): Likewise. * config/rs6000/rs6000.c (rs6000_add_stmt_cost): Likewise. * tree-vect-loop.c (vect_compute_single_scalar_iteration_cost): Likewise. (_loop_vec_info::_loop_vec_info): Init inner_loop_cost_factor. * tree-vectorizer.h (_loop_vec_info): Add inner_loop_cost_factor. (LOOP_VINFO_INNER_LOOP_COST_FACTOR): New macro.
Diffstat (limited to 'gcc/targhooks.c')
-rw-r--r--gcc/targhooks.c9
1 files changed, 8 insertions, 1 deletions
diff --git a/gcc/targhooks.c b/gcc/targhooks.c
index 1947ef2..2d2de04 100644
--- a/gcc/targhooks.c
+++ b/gcc/targhooks.c
@@ -90,6 +90,9 @@ along with GCC; see the file COPYING3. If not see
#include "attribs.h"
#include "asan.h"
#include "emit-rtl.h"
+#include "gimple.h"
+#include "cfgloop.h"
+#include "tree-vectorizer.h"
bool
default_legitimate_address_p (machine_mode mode ATTRIBUTE_UNUSED,
@@ -1480,7 +1483,11 @@ default_add_stmt_cost (class vec_info *vinfo, void *data, int count,
arbitrary and could potentially be improved with analysis. */
if (where == vect_body && stmt_info
&& stmt_in_inner_loop_p (vinfo, stmt_info))
- count *= 50; /* FIXME. */
+ {
+ loop_vec_info loop_vinfo = dyn_cast<loop_vec_info> (vinfo);
+ gcc_assert (loop_vinfo);
+ count *= LOOP_VINFO_INNER_LOOP_COST_FACTOR (loop_vinfo);
+ }
retval = (unsigned) (count * stmt_cost);
cost[where] += retval;