aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTobias Burnus <burnus@net-b.de>2013-10-27 08:40:31 +0100
committerTobias Burnus <burnus@gcc.gnu.org>2013-10-27 08:40:31 +0100
commitd4af74d4e8c0ec9b5303c495d8db1221da02567e (patch)
tree4664d6b8678b602e68c561dc4b261c11351daba7
parentf32311532c085f47de9f75c618ac73fd0e8a638a (diff)
downloadgcc-d4af74d4e8c0ec9b5303c495d8db1221da02567e.zip
gcc-d4af74d4e8c0ec9b5303c495d8db1221da02567e.tar.gz
gcc-d4af74d4e8c0ec9b5303c495d8db1221da02567e.tar.bz2
re PR other/33426 (Support of #pragma ivdep)
2013-10-27 Tobias Burnus <burnus@net-b.de> gcc/c/ PR other/33426 * c-parser.c (c_parser_while_statement, * c_parser_while_statement, c_parser_pragma): Add GCC ivdep support to 'do' and 'while'. (c_parser_statement_after_labels): Update calls. gcc/testsuite/ PR other/33426 * gcc.dg/vect/vect-ivdep-2.c: New. From-SVN: r204102
-rw-r--r--gcc/c/ChangeLog7
-rw-r--r--gcc/c/c-parser.c35
-rw-r--r--gcc/testsuite/ChangeLog5
-rw-r--r--gcc/testsuite/gcc.dg/vect/vect-ivdep-2.c35
4 files changed, 72 insertions, 10 deletions
diff --git a/gcc/c/ChangeLog b/gcc/c/ChangeLog
index a47098f..707c5d2 100644
--- a/gcc/c/ChangeLog
+++ b/gcc/c/ChangeLog
@@ -1,3 +1,10 @@
+2013-10-27 Tobias Burnus <burnus@net-b.de>
+
+ PR other/33426
+ * c-parser.c (c_parser_while_statement, c_parser_while_statement,
+ c_parser_pragma): Add GCC ivdep support to 'do' and 'while'.
+ (c_parser_statement_after_labels): Update calls.
+
2013-10-24 Tobias Burnus <burnus@net-b.de>
PR other/33426
diff --git a/gcc/c/c-parser.c b/gcc/c/c-parser.c
index 4f25078..9ccae3b 100644
--- a/gcc/c/c-parser.c
+++ b/gcc/c/c-parser.c
@@ -1157,8 +1157,8 @@ static void c_parser_statement (c_parser *);
static void c_parser_statement_after_labels (c_parser *);
static void c_parser_if_statement (c_parser *);
static void c_parser_switch_statement (c_parser *);
-static void c_parser_while_statement (c_parser *);
-static void c_parser_do_statement (c_parser *);
+static void c_parser_while_statement (c_parser *, bool);
+static void c_parser_do_statement (c_parser *, bool);
static void c_parser_for_statement (c_parser *, bool);
static tree c_parser_asm_statement (c_parser *);
static tree c_parser_asm_operands (c_parser *);
@@ -4579,10 +4579,10 @@ c_parser_statement_after_labels (c_parser *parser)
c_parser_switch_statement (parser);
break;
case RID_WHILE:
- c_parser_while_statement (parser);
+ c_parser_while_statement (parser, false);
break;
case RID_DO:
- c_parser_do_statement (parser);
+ c_parser_do_statement (parser, false);
break;
case RID_FOR:
c_parser_for_statement (parser, false);
@@ -4912,7 +4912,7 @@ c_parser_switch_statement (c_parser *parser)
*/
static void
-c_parser_while_statement (c_parser *parser)
+c_parser_while_statement (c_parser *parser, bool ivdep)
{
tree block, cond, body, save_break, save_cont;
location_t loc;
@@ -4927,6 +4927,11 @@ c_parser_while_statement (c_parser *parser)
"statement");
cond = error_mark_node;
}
+
+ if (ivdep && cond != error_mark_node)
+ cond = build2 (ANNOTATE_EXPR, TREE_TYPE (cond), cond,
+ build_int_cst (integer_type_node,
+ annot_expr_ivdep_kind));
save_break = c_break_label;
c_break_label = NULL_TREE;
save_cont = c_cont_label;
@@ -4945,7 +4950,7 @@ c_parser_while_statement (c_parser *parser)
*/
static void
-c_parser_do_statement (c_parser *parser)
+c_parser_do_statement (c_parser *parser, bool ivdep)
{
tree block, cond, body, save_break, save_cont, new_break, new_cont;
location_t loc;
@@ -4974,7 +4979,10 @@ c_parser_do_statement (c_parser *parser)
"do-while statement");
cond = error_mark_node;
}
-
+ if (ivdep && cond != error_mark_node)
+ cond = build2 (ANNOTATE_EXPR, TREE_TYPE (cond), cond,
+ build_int_cst (integer_type_node,
+ annot_expr_ivdep_kind));
if (!c_parser_require (parser, CPP_SEMICOLON, "expected %<;%>"))
c_parser_skip_to_end_of_block_or_statement (parser);
c_finish_loop (loc, cond, NULL, body, new_break, new_cont, false);
@@ -9102,12 +9110,19 @@ c_parser_pragma (c_parser *parser, enum pragma_context context)
case PRAGMA_IVDEP:
c_parser_consume_pragma (parser);
c_parser_skip_to_pragma_eol (parser);
- if (!c_parser_next_token_is_keyword (parser, RID_FOR))
+ if (!c_parser_next_token_is_keyword (parser, RID_FOR)
+ && !c_parser_next_token_is_keyword (parser, RID_WHILE)
+ && !c_parser_next_token_is_keyword (parser, RID_DO))
{
- c_parser_error (parser, "for statement expected");
+ c_parser_error (parser, "for, while or do statement expected");
return false;
}
- c_parser_for_statement (parser, true);
+ if (c_parser_next_token_is_keyword (parser, RID_FOR))
+ c_parser_for_statement (parser, true);
+ else if (c_parser_next_token_is_keyword (parser, RID_WHILE))
+ c_parser_while_statement (parser, true);
+ else
+ c_parser_do_statement (parser, true);
return false;
case PRAGMA_GCC_PCH_PREPROCESS:
diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog
index a9aa27d..fa2eb7d 100644
--- a/gcc/testsuite/ChangeLog
+++ b/gcc/testsuite/ChangeLog
@@ -1,3 +1,8 @@
+2013-10-27 Tobias Burnus <burnus@net-b.de>
+
+ PR other/33426
+ * gcc.dg/vect/vect-ivdep-2.c: New.
+
2013-10-26 Oleg Endo <olegendo@gcc.gnu.org>
PR target/52483
diff --git a/gcc/testsuite/gcc.dg/vect/vect-ivdep-2.c b/gcc/testsuite/gcc.dg/vect/vect-ivdep-2.c
new file mode 100644
index 0000000..ff9cb20
--- /dev/null
+++ b/gcc/testsuite/gcc.dg/vect/vect-ivdep-2.c
@@ -0,0 +1,35 @@
+/* { dg-do compile } */
+/* { dg-require-effective-target vect_float } */
+/* { dg-additional-options "-O3 -fopt-info-vec-optimized" } */
+
+/* PR other/33426 */
+/* Testing whether #pragma ivdep is working. */
+
+void foo(int n, int *a, int *b, int *c) {
+ int i;
+ i = 0;
+#pragma GCC ivdep
+ while(i < n)
+ {
+ a[i] = b[i] + c[i];
+ ++i;
+ }
+}
+
+void bar(int n, int *a, int *b, int *c) {
+ int i;
+ i = 0;
+#pragma GCC ivdep
+ do
+ {
+ a[i] = b[i] + c[i];
+ ++i;
+ }
+ while(i < n);
+}
+
+
+/* { dg-message "loop vectorized" "" { target *-*-* } 0 } */
+/* { dg-bogus " version" "" { target *-*-* } 0 } */
+/* { dg-bogus " alias" "" { target *-*-* } 0 } */
+/* { dg-final { cleanup-tree-dump "vect" } } */