aboutsummaryrefslogtreecommitdiff
path: root/gcc/doc
diff options
context:
space:
mode:
authorTamar Christina <tamar.christina@arm.com>2023-08-04 13:50:53 +0100
committerTamar Christina <tamar.christina@arm.com>2023-08-04 13:50:53 +0100
commit73b98860767ac03aa31ad4ca8b73f40484bd7562 (patch)
tree2eadd043502b52f267c5b0fe449c57596c4a5acc /gcc/doc
parent451391a6477f5b012faeca42cdba1bfb8e6eecc0 (diff)
downloadgcc-73b98860767ac03aa31ad4ca8b73f40484bd7562.zip
gcc-73b98860767ac03aa31ad4ca8b73f40484bd7562.tar.gz
gcc-73b98860767ac03aa31ad4ca8b73f40484bd7562.tar.bz2
frontend: Add novector C++ pragma
FORTRAN currently has a pragma NOVECTOR for indicating that vectorization should not be applied to a particular loop. ICC/ICX also has such a pragma for C and C++ called #pragma novector. As part of this patch series I need a way to easily turn off vectorization of particular loops, particularly for testsuite reasons. This patch proposes a #pragma GCC novector that does the same for C++ as gfortan does for FORTRAN and what ICX/ICX does for C++. I added only some basic tests here, but the next patch in the series uses this in the testsuite in about ~800 tests. gcc/cp/ChangeLog: * cp-tree.h (RANGE_FOR_NOVECTOR): New. (cp_convert_range_for, finish_while_stmt_cond, finish_do_stmt, finish_for_cond): Add novector param. * init.cc (build_vec_init): Default novector to false. * method.cc (build_comparison_op): Likewise. * parser.cc (cp_parser_statement): Likewise. (cp_parser_for, cp_parser_c_for, cp_parser_range_for, cp_convert_range_for, cp_parser_iteration_statement, cp_parser_omp_for_loop, cp_parser_pragma): Support novector. (cp_parser_pragma_novector): New. * pt.cc (tsubst_expr): Likewise. * semantics.cc (finish_while_stmt_cond, finish_do_stmt, finish_for_cond): Likewise. gcc/ChangeLog: * doc/extend.texi: Document it. gcc/testsuite/ChangeLog: * g++.dg/vect/vect.exp (support vect- prefix). * g++.dg/vect/vect-novector-pragma.cc: New test.
Diffstat (limited to 'gcc/doc')
-rw-r--r--gcc/doc/extend.texi19
1 files changed, 19 insertions, 0 deletions
diff --git a/gcc/doc/extend.texi b/gcc/doc/extend.texi
index e06caf3..89c5b4e 100644
--- a/gcc/doc/extend.texi
+++ b/gcc/doc/extend.texi
@@ -24581,6 +24581,25 @@ void ignore_vec_dep (int *a, int k, int c, int m)
@}
@end smallexample
+@cindex pragma GCC novector
+@item #pragma GCC novector
+
+With this pragma, the programmer asserts that the following loop should be
+prevented from executing concurrently with SIMD (single instruction multiple
+data) instructions.
+
+For example, the compiler cannot vectorize the following loop with the pragma:
+
+@smallexample
+void foo (int n, int *a, int *b, int *c)
+@{
+ int i, j;
+#pragma GCC novector
+ for (i = 0; i < n; ++i)
+ a[i] = b[i] + c[i];
+@}
+@end smallexample
+
@cindex pragma GCC unroll @var{n}
@item #pragma GCC unroll @var{n}