Hi!

While fixing PR60267, I've noticed that #pragma simd is not registered
when -E -fcilkplus, even when it asks for macro replacements in the clauses.

So, either we have to register it even when preprocessing, so that say for
-save-temps, or other cases of separate preprocessing and separate
compilation you get the macro replacement in there, or #pragma simd doesn't
want to do macro replacement in the clauses, in that case it should call
the cpp_register_deferred_pragma function with false, false rather than
true, false.  But then even #define N 8 ... #pragma simd vectorlength(N)
wouldn't work.

2014-02-19  Jakub Jelinek  <ja...@redhat.com>

        * c-pragma.c (c_pp_lookup_pragma): Handle PRAGMA_CILK_SIMD.
        (init_pragma): Call cpp_register_deferred_pragma for PRAGMA_CILK_SIMD
        even when flag_preprocess_only.

        * c-c++-common/cilk-plus/PS/vectorlength-2.c: New test.
        * c-c++-common/cilk-plus/PS/vectorlength-3.c: New test.

--- gcc/c-family/c-pragma.c.jj  2014-02-19 09:49:08.000000000 +0100
+++ gcc/c-family/c-pragma.c     2014-02-19 10:02:52.148421881 +0100
@@ -1221,6 +1221,13 @@ c_pp_lookup_pragma (unsigned int id, con
        return;
       }
 
+  if (id == PRAGMA_CILK_SIMD)
+    {
+      *space = NULL;
+      *name = "simd";
+      return;
+    }
+
   if (id >= PRAGMA_FIRST_EXTERNAL
       && (id < PRAGMA_FIRST_EXTERNAL + registered_pp_pragmas.length ()))
     {
@@ -1384,7 +1391,7 @@ init_pragma (void)
                                      omp_pragmas_simd[i].id, true, true);
     }
 
-  if (flag_cilkplus && !flag_preprocess_only)
+  if (flag_cilkplus)
     cpp_register_deferred_pragma (parse_in, NULL, "simd", PRAGMA_CILK_SIMD,
                                  true, false);
 
--- gcc/testsuite/c-c++-common/cilk-plus/PS/vectorlength-2.c.jj 2014-02-19 
10:07:10.478961407 +0100
+++ gcc/testsuite/c-c++-common/cilk-plus/PS/vectorlength-2.c    2014-02-19 
10:07:57.005697907 +0100
@@ -0,0 +1,12 @@
+/* { dg-do compile } */
+/* { dg-options "-O2 -fcilkplus" } */
+
+#define vl(n) vectorlength(2*n)
+void
+foo (int *a, int *b, int *c)
+{
+  int i;
+#pragma simd vl(4)
+  for (i = 0; i < 64; i++)
+    a[i] = b[i] * c[i];
+}
--- gcc/testsuite/c-c++-common/cilk-plus/PS/vectorlength-3.c.jj 2014-02-19 
10:07:13.955941631 +0100
+++ gcc/testsuite/c-c++-common/cilk-plus/PS/vectorlength-3.c    2014-02-19 
10:07:49.812737607 +0100
@@ -0,0 +1,14 @@
+/* { dg-do compile } */
+/* { dg-options "-O2 -fcilkplus -save-temps" } */
+
+#define vl(n) vectorlength(2*n)
+void
+foo (int *a, int *b, int *c)
+{
+  int i;
+#pragma simd vl(4)
+  for (i = 0; i < 64; i++)
+    a[i] = b[i] * c[i];
+}
+
+/* { dg-final { cleanup-saved-temps } } */

        Jakub

Reply via email to