diff options
author | Richard Sandiford <richard.sandiford@arm.com> | 2021-11-10 12:31:01 +0000 |
---|---|---|
committer | Richard Sandiford <richard.sandiford@arm.com> | 2021-11-10 12:31:01 +0000 |
commit | 5720a9d5beacb558c1ddccbbfef9f9e4f91b14cf (patch) | |
tree | 3f728ad5f83db3e244ed18b3efb52e90f059de6b /gcc/tree-vectorizer.h | |
parent | 772d76acb5aead98eb3c47a78363d867287d5e77 (diff) | |
download | gcc-5720a9d5beacb558c1ddccbbfef9f9e4f91b14cf.zip gcc-5720a9d5beacb558c1ddccbbfef9f9e4f91b14cf.tar.gz gcc-5720a9d5beacb558c1ddccbbfef9f9e4f91b14cf.tar.bz2 |
vect: Hookize better_loop_vinfo_p
One of the things we want to do on AArch64 is compare vector loops
side-by-side and pick the best one. For some targets, we want this
to be based on issue rates as well as the usual latency-based costs
(at least for loops with relatively high iteration counts).
The current approach to doing this is: when costing vectorisation
candidate A, try to guess what the other main candidate B will look
like and adjust A's latency-based cost up or down based on the likely
difference between A and B's issue rates. This effectively means
that we try to cost parts of B at the same time as A, without actually
being able to see B.
This is needlessly indirect and complex. It was a compromise due
to the code being added (too) late in the GCC 11 cycle, so that
target-independent changes weren't possible.
The target-independent code already compares two candidate loop_vec_infos
side-by-side, so that information about A and B above are available
directly. This patch creates a way for targets to hook into this
comparison.
The AArch64 code can therefore hook into better_main_loop_than_p to
compare issue rates. If the issue rate comparison isn't decisive,
the code can fall back to the normal latency-based comparison instead.
gcc/
* tree-vectorizer.h (vector_costs::better_main_loop_than_p)
(vector_costs::better_epilogue_loop_than_p)
(vector_costs::compare_inside_loop_cost)
(vector_costs::compare_outside_loop_cost): Likewise.
* tree-vectorizer.c (vector_costs::better_main_loop_than_p)
(vector_costs::better_epilogue_loop_than_p)
(vector_costs::compare_inside_loop_cost)
(vector_costs::compare_outside_loop_cost): New functions,
containing code moved from...
* tree-vect-loop.c (vect_better_loop_vinfo_p): ...here.
Diffstat (limited to 'gcc/tree-vectorizer.h')
-rw-r--r-- | gcc/tree-vectorizer.h | 17 |
1 files changed, 17 insertions, 0 deletions
diff --git a/gcc/tree-vectorizer.h b/gcc/tree-vectorizer.h index 72eed98..9b41995 100644 --- a/gcc/tree-vectorizer.h +++ b/gcc/tree-vectorizer.h @@ -1419,6 +1419,21 @@ public: read back using the functions below. */ virtual void finish_cost (); + /* The costs in THIS and OTHER both describe ways of vectorizing + a main loop. Return true if the costs described by THIS are + cheaper than the costs described by OTHER. Return false if any + of the following are true: + + - THIS and OTHER are of equal cost + - OTHER is better than THIS + - we can't be sure about the relative costs of THIS and OTHER. */ + virtual bool better_main_loop_than_p (const vector_costs *other) const; + + /* Likewise, but the costs in THIS and OTHER both describe ways of + vectorizing an epilogue loop of MAIN_LOOP. */ + virtual bool better_epilogue_loop_than_p (const vector_costs *other, + loop_vec_info main_loop) const; + unsigned int prologue_cost () const; unsigned int body_cost () const; unsigned int epilogue_cost () const; @@ -1429,6 +1444,8 @@ protected: unsigned int); unsigned int adjust_cost_for_freq (stmt_vec_info, vect_cost_model_location, unsigned int); + int compare_inside_loop_cost (const vector_costs *) const; + int compare_outside_loop_cost (const vector_costs *) const; /* The region of code that we're considering vectorizing. */ vec_info *m_vinfo; |