From 7d125162896d1e33a18e88a114a1618f4805f531 Mon Sep 17 00:00:00 2001 From: "Balaji V. Iyer" Date: Thu, 21 Mar 2013 03:27:13 +0000 Subject: Fixed pragma simd vectorlenght clause to accept multiple values with comma. 2013-03-20 Balaji V. Iyer * c/c-parser.c (c_parser_simd_vectorlength): Called the function c_parser_expr_no_commas instead of c_parser_expression to parse just until the comma. git-svn-id: https://gcc.gnu.org/svn/gcc/branches/cilkplus@196854 138bc75d-0d04-0410-961f-82ee72b054a4 --- gcc/ChangeLog.cilkplus | 6 ++++++ gcc/c/c-parser.c | 2 +- gcc/testsuite/ChangeLog.cilkplus | 6 ++++++ .../array_notation_tests/compile/array_test2.c | 2 +- .../pragma_simd_tests/compile/cond_vlength.c | 2 +- .../pragma_simd_tests/execute/vlength_comma.c | 24 ++++++++++++++++++++++ .../pragma_simd_tests/execute/vlength_comma2.c | 24 ++++++++++++++++++++++ .../pragma_simd_tests/execute/vlength_comma3.c | 24 ++++++++++++++++++++++ 8 files changed, 87 insertions(+), 3 deletions(-) create mode 100644 gcc/testsuite/gcc.dg/cilk-plus/pragma_simd_tests/execute/vlength_comma.c create mode 100644 gcc/testsuite/gcc.dg/cilk-plus/pragma_simd_tests/execute/vlength_comma2.c create mode 100644 gcc/testsuite/gcc.dg/cilk-plus/pragma_simd_tests/execute/vlength_comma3.c diff --git a/gcc/ChangeLog.cilkplus b/gcc/ChangeLog.cilkplus index 674b21444a8..c0738183de5 100644 --- a/gcc/ChangeLog.cilkplus +++ b/gcc/ChangeLog.cilkplus @@ -1,3 +1,9 @@ +2013-03-20 Balaji V. Iyer + + * c/c-parser.c (c_parser_simd_vectorlength): Called the function + c_parser_expr_no_commas instead of c_parser_expression to parse just + until the comma. + 2013-03-13 Balaji V. Iyer * c/c-parser.c (c_parser_simd_vectorlength): Allow using sizeof diff --git a/gcc/c/c-parser.c b/gcc/c/c-parser.c index 7fae70f1611..f00d28d50c7 100644 --- a/gcc/c/c-parser.c +++ b/gcc/c/c-parser.c @@ -9090,7 +9090,7 @@ c_parser_simd_vectorlength (c_parser *parser) while (true) { tree token_value = NULL_TREE; - token_value = c_parser_expression (parser).value; + token_value = c_parser_expr_no_commas (parser, NULL).value; if (!TREE_TYPE (token_value) || !TREE_CONSTANT (token_value) || !INTEGRAL_TYPE_P (TREE_TYPE (token_value))) { diff --git a/gcc/testsuite/ChangeLog.cilkplus b/gcc/testsuite/ChangeLog.cilkplus index a4c041a4bb1..16ed5e60ee5 100644 --- a/gcc/testsuite/ChangeLog.cilkplus +++ b/gcc/testsuite/ChangeLog.cilkplus @@ -1,3 +1,9 @@ +2013-03-20 Balaji V. Iyer + + * gcc.dg/cilk-plus/pragma_simd_tests/execute/vlength_comma.c: New test + * gcc.dg/cilk-plus/pragma_simd_tests/execute/vlength_comma2.c: New test + * gcc.dg/cilk-plus/pragma_simd_tests/execute/vlength_comma3.c: New test + 2013-03-15 Balaji V. Iyer * gcc.dg/cilk-plus/array_notation_tests/compile/array_test1.c (main): diff --git a/gcc/testsuite/gcc.dg/cilk-plus/array_notation_tests/compile/array_test2.c b/gcc/testsuite/gcc.dg/cilk-plus/array_notation_tests/compile/array_test2.c index 5fb3680c25c..fd128b1c589 100644 --- a/gcc/testsuite/gcc.dg/cilk-plus/array_notation_tests/compile/array_test2.c +++ b/gcc/testsuite/gcc.dg/cilk-plus/array_notation_tests/compile/array_test2.c @@ -26,7 +26,7 @@ int main(int argc, char **argv) array[ii] = 10; array2[ii] = 5000000; } - array2[0:10:2] = array[0:10:2]; + array2[0:5:2] = array[0:5:2]; printf("==============================================\n"); for (ii = 0; ii<10; ii++) diff --git a/gcc/testsuite/gcc.dg/cilk-plus/pragma_simd_tests/compile/cond_vlength.c b/gcc/testsuite/gcc.dg/cilk-plus/pragma_simd_tests/compile/cond_vlength.c index 113f0dd1ce7..52677f30053 100644 --- a/gcc/testsuite/gcc.dg/cilk-plus/pragma_simd_tests/compile/cond_vlength.c +++ b/gcc/testsuite/gcc.dg/cilk-plus/pragma_simd_tests/compile/cond_vlength.c @@ -7,7 +7,7 @@ int main () float a[256]; // The line below should be OK! - #pragma simd vectorlength(sizeof (a) == sizeof (float) ? 8 : 4) + #pragma simd vectorlength(sizeof (a) == sizeof (float) ? 4 : 8) for (i = 0; i < 256; i++) { a[i] = i; diff --git a/gcc/testsuite/gcc.dg/cilk-plus/pragma_simd_tests/execute/vlength_comma.c b/gcc/testsuite/gcc.dg/cilk-plus/pragma_simd_tests/execute/vlength_comma.c new file mode 100644 index 00000000000..2f62bae660e --- /dev/null +++ b/gcc/testsuite/gcc.dg/cilk-plus/pragma_simd_tests/execute/vlength_comma.c @@ -0,0 +1,24 @@ +int a[100]; + +int +main (int argc, char **argv) +{ + int i; + + for (i = 0; i < 100; i++) + if (argc == 1) + a[i] = 10; + else + a[i] = argc * 5; + +#pragma simd vectorlength(4, 8) + for (i = 0; i < 100; i++) + a[i] += 1; + + for (i = 0; i < 100; i++) + if (a[i] != 11) + return 1; + + return 0; +} + diff --git a/gcc/testsuite/gcc.dg/cilk-plus/pragma_simd_tests/execute/vlength_comma2.c b/gcc/testsuite/gcc.dg/cilk-plus/pragma_simd_tests/execute/vlength_comma2.c new file mode 100644 index 00000000000..b049c507d92 --- /dev/null +++ b/gcc/testsuite/gcc.dg/cilk-plus/pragma_simd_tests/execute/vlength_comma2.c @@ -0,0 +1,24 @@ +int a[100]; + +int +main (int argc, char **argv) +{ + int i; + + for (i = 0; i < 100; i++) + if (argc == 1) + a[i] = 10; + else + a[i] = argc * 5; + +#pragma simd vectorlength(4, 8, sizeof (int) == 4 ? 4 : 8) + for (i = 0; i < 100; i++) + a[i] += 1; + + for (i = 0; i < 100; i++) + if (a[i] != 11) + return 1; + + return 0; +} + diff --git a/gcc/testsuite/gcc.dg/cilk-plus/pragma_simd_tests/execute/vlength_comma3.c b/gcc/testsuite/gcc.dg/cilk-plus/pragma_simd_tests/execute/vlength_comma3.c new file mode 100644 index 00000000000..014005b7b25 --- /dev/null +++ b/gcc/testsuite/gcc.dg/cilk-plus/pragma_simd_tests/execute/vlength_comma3.c @@ -0,0 +1,24 @@ +int a[100]; + +int +main (int argc, char **argv) +{ + int i; + + for (i = 0; i < 100; i++) + if (argc == 1) + a[i] = 10; + else + a[i] = argc * 5; + +#pragma simd vectorlength(4, sizeof (int) == 4 ? 4 : 8, 8) + for (i = 0; i < 100; i++) + a[i] += 1; + + for (i = 0; i < 100; i++) + if (a[i] != 11) + return 1; + + return 0; +} + -- cgit v1.2.3