Add support for conditional reductions using SVE CLASTB

Programming / Compilers / GCC - rsandifo [138bc75d-0d04-0410-961f-82ee72b054a4] - 13 January 2018 17:59 EST

This patch uses SVE CLASTB to optimise conditional reductions. It means that we no longer need to maintain a separate index vector to record the most recent valid value, and no longer need to worry about overflow cases.

2018-01-13 Richard Sandiford Alan Hayward David Sherwood

gcc/
- doc/md.texi (fold_extract_last_@var{m}): Document.
- doc/sourcebuild.texi (vect_fold_extract_last): Likewise.
- optabs.def (fold_extract_last_optab): New optab.
- internal-fn.def (FOLD_EXTRACT_LAST): New internal function.
- internal-fn.c (fold_extract_direct): New macro. (expand_fold_extract_optab_fn): Likewise. (direct_fold_extract_optab_supported_p): Likewise.
- tree-vectorizer.h (EXTRACT_LAST_REDUCTION): New vect_reduction_type.
- tree-vect-loop.c (vect_model_reduction_cost): Handle EXTRACT_LAST_REDUCTION. (get_initial_def_for_reduction): Do not create an initial vector for EXTRACT_LAST_REDUCTION reductions. (vectorizable_reduction): Leave the scalar phi in place for EXTRACT_LAST_REDUCTIONs. Try using EXTRACT_LAST_REDUCTION ahead of INTEGER_INDUC_COND_REDUCTION. Do not check for an epilogue code for EXTRACT_LAST_REDUCTION and defer the transform phase to vectorizable_condition.
- tree-vect-stmts.c (vect_finish_stmt_generation_1): New function, split out from... (vect_finish_stmt_generation): ...here. (vect_finish_replace_stmt): New function. (vectorizable_condition): Handle EXTRACT_LAST_REDUCTION.
- config/aarch64/aarch64-sve.md (fold_extract_last_): New pattern.
- config/aarch64/aarch64.md (UNSPEC_CLASTB): New unspec.

gcc/testsuite/
- lib/target-supports.exp (check_effective_target_vect_fold_extract_last): New proc.
- gcc.dg/vect/pr65947-1.c: Update dump messages. Add markup for fold_extract_last.
- gcc.dg/vect/pr65947-2.c: Likewise.
- gcc.dg/vect/pr65947-3.c: Likewise.
- gcc.dg/vect/pr65947-4.c: Likewise.
- gcc.dg/vect/pr65947-5.c: Likewise.
- gcc.dg/vect/pr65947-6.c: Likewise.
- gcc.dg/vect/pr65947-9.c: Likewise.
- gcc.dg/vect/pr65947-10.c: Likewise.
- gcc.dg/vect/pr65947-12.c: Likewise.
- gcc.dg/vect/pr65947-14.c: Likewise.
- gcc.dg/vect/pr80631-1.c: Likewise.
- gcc.target/aarch64/sve/clastb_1.c: New test.
- gcc.target/aarch64/sve/clastb_1_run.c: Likewise.
- gcc.target/aarch64/sve/clastb_2.c: Likewise.
- gcc.target/aarch64/sve/clastb_2_run.c: Likewise.
- gcc.target/aarch64/sve/clastb_3.c: Likewise.
- gcc.target/aarch64/sve/clastb_3_run.c: Likewise.
- gcc.target/aarch64/sve/clastb_4.c: Likewise.
- gcc.target/aarch64/sve/clastb_4_run.c: Likewise.
- gcc.target/aarch64/sve/clastb_5.c: Likewise.
- gcc.target/aarch64/sve/clastb_5_run.c: Likewise.
- gcc.target/aarch64/sve/clastb_6.c: Likewise.
- gcc.target/aarch64/sve/clastb_6_run.c: Likewise.
- gcc.target/aarch64/sve/clastb_7.c: Likewise.
- gcc.target/aarch64/sve/clastb_7_run.c: Likewise.

3bf95150f68 Add support for conditional reductions using SVE CLASTB
gcc/ChangeLog | 30 +++++
gcc/config/aarch64/aarch64-sve.md | 15 +++
gcc/config/aarch64/aarch64.md | 1 +
gcc/doc/md.texi | 9 ++
gcc/doc/sourcebuild.texi | 3 +
gcc/internal-fn.c | 5 +
gcc/internal-fn.def | 5 +
gcc/optabs.def | 1 +
gcc/testsuite/ChangeLog | 33 ++++++
gcc/testsuite/gcc.dg/vect/pr65947-1.c | 3 +-
gcc/testsuite/gcc.dg/vect/pr65947-10.c | 1 +
gcc/testsuite/gcc.dg/vect/pr65947-12.c | 1 +
gcc/testsuite/gcc.dg/vect/pr65947-14.c | 3 +-
gcc/testsuite/gcc.dg/vect/pr65947-2.c | 1 +
gcc/testsuite/gcc.dg/vect/pr65947-3.c | 1 +
gcc/testsuite/gcc.dg/vect/pr65947-4.c | 3 +-
gcc/testsuite/gcc.dg/vect/pr65947-5.c | 6 +-
gcc/testsuite/gcc.dg/vect/pr65947-6.c | 1 +
gcc/testsuite/gcc.dg/vect/pr65947-9.c | 7 +-
gcc/testsuite/gcc.dg/vect/pr80631-1.c | 3 +-
gcc/testsuite/gcc.target/aarch64/sve/clastb_1.c | 20 ++++
.../gcc.target/aarch64/sve/clastb_1_run.c | 22 ++++
gcc/testsuite/gcc.target/aarch64/sve/clastb_2.c | 26 +++++
.../gcc.target/aarch64/sve/clastb_2_run.c | 23 ++++
gcc/testsuite/gcc.target/aarch64/sve/clastb_3.c | 8 ++
.../gcc.target/aarch64/sve/clastb_3_run.c | 23 ++++
gcc/testsuite/gcc.target/aarch64/sve/clastb_4.c | 8 ++
.../gcc.target/aarch64/sve/clastb_4_run.c | 25 ++++
gcc/testsuite/gcc.target/aarch64/sve/clastb_5.c | 8 ++
.../gcc.target/aarch64/sve/clastb_5_run.c | 23 ++++
gcc/testsuite/gcc.target/aarch64/sve/clastb_6.c | 24 ++++
.../gcc.target/aarch64/sve/clastb_6_run.c | 22 ++++
gcc/testsuite/gcc.target/aarch64/sve/clastb_7.c | 7 ++
.../gcc.target/aarch64/sve/clastb_7_run.c | 22 ++++
gcc/testsuite/lib/target-supports.exp | 6 +
gcc/tree-vect-loop.c | 129 ++++++++++++++-------
gcc/tree-vect-stmts.c | 112 +++++++++++++-----
gcc/tree-vectorizer.h | 9 +-
38 files changed, 569 insertions(+), 80 deletions(-)

Upstream: gcc.gnu.org


  • Share