This patch ensures that we properly expand gomp SIMD builtins even with
-fno-tree-loop-optimize.  The problem was that we didn't run the 
loop vectorization at all.  -fno-tree-loop-vectorize already contains
similar hack.

Regtested/bootstrapped on x86_64-linux, ok for trunk (or for 5.0?)?

2014-03-17  Marek Polacek  <pola...@redhat.com>

        PR middle-end/60534
        * omp-low.c (omp_max_vf): Treat -fno-tree-loop-optimize the same
        as -fno-tree-loop-vectorize.
        (expand_omp_simd): Likewise.
testsuite/
        * gcc.dg/gomp/pr60534.c: New test.

diff --git gcc/omp-low.c gcc/omp-low.c
index 91c8656..fdf3367 100644
--- gcc/omp-low.c
+++ gcc/omp-low.c
@@ -2931,7 +2931,8 @@ omp_max_vf (void)
       || optimize_debug
       || (!flag_tree_loop_vectorize
          && (global_options_set.x_flag_tree_loop_vectorize
-              || global_options_set.x_flag_tree_vectorize)))
+             || global_options_set.x_flag_tree_vectorize
+             || global_options_set.x_flag_tree_loop_optimize)))
     return 1;
 
   int vs = targetm.vectorize.autovectorize_vector_sizes ();
@@ -6834,11 +6835,12 @@ expand_omp_simd (struct omp_region *region, struct 
omp_for_data *fd)
          loop->simduid = OMP_CLAUSE__SIMDUID__DECL (simduid);
          cfun->has_simduid_loops = true;
        }
-      /* If not -fno-tree-loop-vectorize, hint that we want to vectorize
-        the loop.  */
+      /* If not -fno-tree-loop-vectorize of -fno-tree-loop-optimize,
+         hint that we want to vectorize the loop.  */
       if ((flag_tree_loop_vectorize
           || (!global_options_set.x_flag_tree_loop_vectorize
-               && !global_options_set.x_flag_tree_vectorize))
+              && !global_options_set.x_flag_tree_vectorize
+              && !global_options_set.x_flag_tree_loop_optimize))
          && loop->safelen > 1)
        {
          loop->force_vect = true;
diff --git gcc/testsuite/gcc.dg/gomp/pr60534.c 
gcc/testsuite/gcc.dg/gomp/pr60534.c
index e69de29..f8a6bdc 100644
--- gcc/testsuite/gcc.dg/gomp/pr60534.c
+++ gcc/testsuite/gcc.dg/gomp/pr60534.c
@@ -0,0 +1,16 @@
+/* PR middle-end/60534 */
+/* { dg-do compile } */
+/* { dg-options "-fopenmp -O -fno-tree-loop-optimize" } */
+
+extern int d[];
+
+int
+foo (int a)
+{
+  int c = 0;
+  int l;
+#pragma omp simd reduction(+: c)
+  for (l = 0; l < a; ++l)
+    c += d[l];
+  return c;
+}

        Marek

Reply via email to