![]() Unroll and jam can sometimes leave redundancies. E.g. for: for (int j = 0; j < 100; ++j) for (int i = 0; i < 100; ++i) x[i] += y[i] * z[j][i]; the new loop will do the equivalent of: for (int j = 0; j < 100; j += 2) for (int i = 0; i < 100; ++i) { x[i] += y[i] * z[j][i]; x[i] += y[i] * z[j + 1][i]; } with two reads of y[i] and with a round trip through memory for x[i]. At the moment these redundancies survive till vectorisation, so if vectorisation succeeds, we're reliant on being able to remove the redundancies from the vector form. This can be hard to do if a vector loop uses predication. E.g. on SVE we end up with: .L3: ld1w z3.s, p0/z, [x3, x0, lsl 2] ld1w z0.s, p0/z, [x5, x0, lsl 2] ld1w z1.s, p0/z, [x2, x0, lsl 2] mad z1.s, p1/m, z0.s, z3.s ld1w z2.s, p0/z, [x4, x0, lsl 2] st1w z1.s, p0, [x3, x0, lsl 2] // store to x[i] ld1w z1.s, p0/z, [x3, x0, lsl 2] // load back from x[i] mad z0.s, p1/m, z2.s, z1.s st1w z0.s, p0, [x3, x0, lsl 2] add x0, x0, x6 whilelo p0.s, w0, w1 b.any .L3 This patch runs a value-numbering pass on loops after a successful unroll-and-jam, which gets rid of the unnecessary load and gives a more accurate idea of vector costs. Unfortunately the redundant store still persists without a pre-vect DSE, but that feels like a separate issue. Note that the pass requires the loop to have a single exit, hence the simple calculation of exit_bbs. gcc/ * gimple-loop-jam.c: Include tree-ssa-sccvn.h. (tree_loop_unroll_and_jam): Run value-numbering on a loop that has been successfully unrolled. gcc/testsuite/ * gcc.dg/unroll-10.c: New test. |
||
---|---|---|
c++tools | ||
config | ||
contrib | ||
fixincludes | ||
gcc | ||
gnattools | ||
gotools | ||
include | ||
INSTALL | ||
intl | ||
libada | ||
libatomic | ||
libbacktrace | ||
libcc1 | ||
libcody | ||
libcpp | ||
libdecnumber | ||
libffi | ||
libgcc | ||
libgfortran | ||
libgo | ||
libgomp | ||
libiberty | ||
libitm | ||
libobjc | ||
liboffloadmic | ||
libphobos | ||
libquadmath | ||
libsanitizer | ||
libssp | ||
libstdc++-v3 | ||
libvtv | ||
lto-plugin | ||
maintainer-scripts | ||
zlib | ||
.dir-locals.el | ||
.gitattributes | ||
.gitignore | ||
ABOUT-NLS | ||
ar-lib | ||
ChangeLog | ||
ChangeLog.jit | ||
ChangeLog.tree-ssa | ||
compile | ||
config-ml.in | ||
config.guess | ||
config.rpath | ||
config.sub | ||
configure | ||
configure.ac | ||
COPYING | ||
COPYING.LIB | ||
COPYING.RUNTIME | ||
COPYING3 | ||
COPYING3.LIB | ||
depcomp | ||
install-sh | ||
libtool-ldflags | ||
libtool.m4 | ||
ltgcc.m4 | ||
ltmain.sh | ||
ltoptions.m4 | ||
ltsugar.m4 | ||
ltversion.m4 | ||
lt~obsolete.m4 | ||
MAINTAINERS | ||
Makefile.def | ||
Makefile.in | ||
Makefile.tpl | ||
missing | ||
mkdep | ||
mkinstalldirs | ||
move-if-change | ||
multilib.am | ||
README | ||
symlink-tree | ||
test-driver | ||
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.