Go to file
Richard Sandiford b781a135a0 Add support for in-order addition reduction using SVE FADDA
This patch adds support for in-order floating-point addition reductions,
which are suitable even in strict IEEE mode.

Previously vect_is_simple_reduction would reject any cases that forbid
reassociation.  The idea is instead to tentatively accept them as
"FOLD_LEFT_REDUCTIONs" and only fail later if there is no support
for them.  Although this patch only handles the particular case of plus
and minus on floating-point types, there's no reason in principle why
we couldn't handle other cases.

The reductions use a new fold_left_plus_optab if available, otherwise
they fall back to elementwise additions or subtractions.

The vect_force_simple_reduction change makes it easier for parloops
to read the type of reduction.

2018-01-13  Richard Sandiford  <richard.sandiford@linaro.org>
	    Alan Hayward  <alan.hayward@arm.com>
	    David Sherwood  <david.sherwood@arm.com>

gcc/
	* optabs.def (fold_left_plus_optab): New optab.
	* doc/md.texi (fold_left_plus_@var{m}): Document.
	* internal-fn.def (IFN_FOLD_LEFT_PLUS): New internal function.
	* internal-fn.c (fold_left_direct): Define.
	(expand_fold_left_optab_fn): Likewise.
	(direct_fold_left_optab_supported_p): Likewise.
	* fold-const-call.c (fold_const_fold_left): New function.
	(fold_const_call): Use it to fold CFN_FOLD_LEFT_PLUS.
	* tree-parloops.c (valid_reduction_p): New function.
	(gather_scalar_reductions): Use it.
	* tree-vectorizer.h (FOLD_LEFT_REDUCTION): New vect_reduction_type.
	(vect_finish_replace_stmt): Declare.
	* tree-vect-loop.c (fold_left_reduction_fn): New function.
	(needs_fold_left_reduction_p): New function, split out from...
	(vect_is_simple_reduction): ...here.  Accept reductions that
	forbid reassociation, but give them type FOLD_LEFT_REDUCTION.
	(vect_force_simple_reduction): Also store the reduction type in
	the assignment's STMT_VINFO_REDUC_TYPE.
	(vect_model_reduction_cost): Handle FOLD_LEFT_REDUCTION.
	(merge_with_identity): New function.
	(vect_expand_fold_left): Likewise.
	(vectorize_fold_left_reduction): Likewise.
	(vectorizable_reduction): Handle FOLD_LEFT_REDUCTION.  Leave the
	scalar phi in place for it.  Check for target support and reject
	cases that would reassociate the operation.  Defer the transform
	phase to vectorize_fold_left_reduction.
	* config/aarch64/aarch64.md (UNSPEC_FADDA): New unspec.
	* config/aarch64/aarch64-sve.md (fold_left_plus_<mode>): New expander.
	(*fold_left_plus_<mode>, *pred_fold_left_plus_<mode>): New insns.

gcc/testsuite/
	* gcc.dg/vect/no-fast-math-vect16.c: Expect the test to pass and
	check for a message about using in-order reductions.
	* gcc.dg/vect/pr79920.c: Expect both loops to be vectorized and
	check for a message about using in-order reductions.
	* gcc.dg/vect/trapv-vect-reduc-4.c: Expect all three loops to be
	vectorized and check for a message about using in-order reductions.
	Expect targets with variable-length vectors to fall back to the
	fixed-length mininum.
	* gcc.dg/vect/vect-reduc-6.c: Expect the loop to be vectorized and
	check for a message about using in-order reductions.
	* gcc.dg/vect/vect-reduc-in-order-1.c: New test.
	* gcc.dg/vect/vect-reduc-in-order-2.c: Likewise.
	* gcc.dg/vect/vect-reduc-in-order-3.c: Likewise.
	* gcc.dg/vect/vect-reduc-in-order-4.c: Likewise.
	* gcc.target/aarch64/sve/reduc_strict_1.c: New test.
	* gcc.target/aarch64/sve/reduc_strict_1_run.c: Likewise.
	* gcc.target/aarch64/sve/reduc_strict_2.c: Likewise.
	* gcc.target/aarch64/sve/reduc_strict_2_run.c: Likewise.
	* gcc.target/aarch64/sve/reduc_strict_3.c: Likewise.
	* gcc.target/aarch64/sve/slp_13.c: Add floating-point types.
	* gfortran.dg/vect/vect-8.f90: Expect 22 loops to be vectorized if
	vect_fold_left_plus.

Co-Authored-By: Alan Hayward <alan.hayward@arm.com>
Co-Authored-By: David Sherwood <david.sherwood@arm.com>

From-SVN: r256639
2018-01-13 18:01:24 +00:00
config
contrib * update-copyright.py: Skip pdt-5.f03 in gfortran.dg subdir. 2018-01-03 11:00:43 +01:00
fixincludes
gcc Add support for in-order addition reduction using SVE FADDA 2018-01-13 18:01:24 +00:00
gnattools Update copyright years. 2018-01-03 11:03:58 +01:00
gotools libgo: update to Go1.10beta1 2018-01-09 01:23:08 +00:00
include Update copyright years. 2018-01-03 11:03:58 +01:00
INSTALL
intl
libada Update copyright years. 2018-01-03 11:03:58 +01:00
libatomic Update copyright years. 2018-01-03 11:03:58 +01:00
libbacktrace Update copyright years. 2018-01-03 11:03:58 +01:00
libcc1 Update copyright years. 2018-01-03 11:03:58 +01:00
libcpp Update copyright years. 2018-01-03 11:03:58 +01:00
libdecnumber Update copyright years. 2018-01-03 11:03:58 +01:00
libffi
libgcc SVE unwinding 2018-01-13 17:56:52 +00:00
libgfortran PR 78534 Regression on 32-bit targets 2018-01-08 14:12:05 +02:00
libgo re PR go/83794 (misc/cgo/test uses gigabytes of memory) 2018-01-11 19:58:55 +00:00
libgomp Update copyright years. 2018-01-03 11:03:58 +01:00
libhsail-rt Update copyright years. 2018-01-03 11:03:58 +01:00
libiberty re PR lto/81968 (early lto debug objects make Solaris ld SEGV) 2018-01-11 12:12:39 +00:00
libitm Update copyright years. 2018-01-03 11:03:58 +01:00
libmpx
libobjc Update copyright years. 2018-01-03 11:03:58 +01:00
liboffloadmic Update copyright years. 2018-01-03 11:03:58 +01:00
libquadmath Update copyright years. 2018-01-03 11:03:58 +01:00
libsanitizer invoke.texi: Document the options. 2017-12-05 10:23:25 +01:00
libssp Update copyright years. 2018-01-03 11:03:58 +01:00
libstdc++-v3 Link with correct values-*.o files on Solaris (PR target/40411) 2018-01-12 09:52:53 +00:00
libvtv Update copyright years. 2018-01-03 11:03:58 +01:00
lto-plugin Update copyright years. 2018-01-03 11:03:58 +01:00
maintainer-scripts
zlib
.dir-locals.el
.gitattributes
.gitignore
ABOUT-NLS
ChangeLog Update copyright years. 2018-01-03 11:03:58 +01:00
ChangeLog.jit
ChangeLog.tree-ssa
compile
config-ml.in
config.guess config.guess: Import latest version. 2018-01-03 15:25:18 +11:00
config.rpath
config.sub config.guess: Import latest version. 2018-01-03 15:25:18 +11:00
configure configure.ac: Remove logic adding gdb to noconfigsdirs for or1k. 2017-12-12 14:23:05 +00:00
configure.ac configure.ac: Remove logic adding gdb to noconfigsdirs for or1k. 2017-12-12 14:23:05 +00:00
COPYING
COPYING3
COPYING3.LIB
COPYING.LIB
COPYING.RUNTIME
depcomp
install-sh
libtool-ldflags
libtool.m4
lt~obsolete.m4
ltgcc.m4
ltmain.sh
ltoptions.m4
ltsugar.m4
ltversion.m4
MAINTAINERS Updated email in MAINTAINERS file. 2017-12-12 17:40:24 +00:00
Makefile.def Remove Cilk Plus support. 2017-11-28 11:35:37 +01:00
Makefile.in Remove Cilk Plus support. 2017-11-28 11:35:37 +01:00
Makefile.tpl
missing
mkdep
mkinstalldirs
move-if-change
README
symlink-tree
ylwrap

This directory contains the GNU Compiler Collection (GCC).

The GNU Compiler Collection is free software.  See the files whose
names start with COPYING for copying permission.  The manuals, and
some of the runtime libraries, are under different terms; see the
individual source files for details.

The directory INSTALL contains copies of the installation information
as HTML and plain text.  The source of this information is
gcc/doc/install.texi.  The installation information includes details
of what is included in the GCC sources and what files GCC installs.

See the file gcc/doc/gcc.texi (together with other files that it
includes) for usage and porting information.  An online readable
version of the manual is in the files gcc/doc/gcc.info*.

See http://gcc.gnu.org/bugs/ for how to report bugs usefully.

Copyright years on GCC source files may be listed using range
notation, e.g., 1987-2012, indicating that every year in the range,
inclusive, is a copyrightable year that could otherwise be listed
individually.