]> git.ipfire.org Git - thirdparty/gcc.git/commitdiff
re PR libgomp/58756 (FAIL: libgomp.c/pr58392.c execution test)
authorJakub Jelinek <jakub@redhat.com>
Mon, 16 Dec 2013 10:34:28 +0000 (11:34 +0100)
committerJakub Jelinek <jakub@gcc.gnu.org>
Mon, 16 Dec 2013 10:34:28 +0000 (11:34 +0100)
PR libgomp/58756
* omp-low.c (lower_rec_input_clauses) <case OMP_CLAUSE_REDUCTION>: For
reductions without placeholder if is_simd, but when not using
GOMP_SIMD* internal calls, also perform the reduction operation
on the outer var rather than simple assignment.

* testsuite/libgomp.c/pr58756.c: New test.

From-SVN: r206011

gcc/ChangeLog
gcc/omp-low.c
libgomp/ChangeLog
libgomp/testsuite/libgomp.c/pr58756.c [new file with mode: 0644]

index accfc234e32c1df3d25a6c6a616f2b40e11bbfa8..a3821a88a805c1cb2b0370b9469651b82933296b 100644 (file)
@@ -1,4 +1,13 @@
+2013-12-16  Jakub Jelinek  <jakub@redhat.com>
+
+       PR libgomp/58756
+       * omp-low.c (lower_rec_input_clauses) <case OMP_CLAUSE_REDUCTION>: For
+       reductions without placeholder if is_simd, but when not using
+       GOMP_SIMD* internal calls, also perform the reduction operation
+       on the outer var rather than simple assignment.
+
 2013-12-16  Yuri Rumyantsev  <ysrumyan@gmail.com>
+
        * config/i386/i386.c (slm_cost): Fix imul cost for HI.
 
 2013-12-16  Jakub Jelinek  <jakub@redhat.com>
index 05fca4096fc250246d255ffb3ad2e611f103278d..97092dd089479993de65b535ec9a404c894430da 100644 (file)
@@ -3565,20 +3565,21 @@ lower_rec_input_clauses (tree clauses, gimple_seq *ilist, gimple_seq *dlist,
                {
                  x = omp_reduction_init (c, TREE_TYPE (new_var));
                  gcc_assert (TREE_CODE (TREE_TYPE (new_var)) != ARRAY_TYPE);
+                 enum tree_code code = OMP_CLAUSE_REDUCTION_CODE (c);
+
+                 /* reduction(-:var) sums up the partial results, so it
+                    acts identically to reduction(+:var).  */
+                 if (code == MINUS_EXPR)
+                   code = PLUS_EXPR;
+
                  if (is_simd
                      && lower_rec_simd_input_clauses (new_var, ctx, max_vf,
                                                       idx, lane, ivar, lvar))
                    {
-                     enum tree_code code = OMP_CLAUSE_REDUCTION_CODE (c);
                      tree ref = build_outer_var_ref (var, ctx);
 
                      gimplify_assign (unshare_expr (ivar), x, &llist[0]);
 
-                     /* reduction(-:var) sums up the partial results, so it
-                        acts identically to reduction(+:var).  */
-                     if (code == MINUS_EXPR)
-                       code = PLUS_EXPR;
-
                      x = build2 (code, TREE_TYPE (ref), ref, ivar);
                      ref = build_outer_var_ref (var, ctx);
                      gimplify_assign (ref, x, &llist[1]);
@@ -3587,8 +3588,13 @@ lower_rec_input_clauses (tree clauses, gimple_seq *ilist, gimple_seq *dlist,
                    {
                      gimplify_assign (new_var, x, ilist);
                      if (is_simd)
-                       gimplify_assign (build_outer_var_ref (var, ctx),
-                                        new_var, dlist);
+                       {
+                         tree ref = build_outer_var_ref (var, ctx);
+
+                         x = build2 (code, TREE_TYPE (ref), ref, new_var);
+                         ref = build_outer_var_ref (var, ctx);
+                         gimplify_assign (ref, x, dlist);
+                       }
                    }
                }
              break;
index bdcc930d97bd604704f8dbe45cbabcc56406d2d5..566a4c1275205570e7f3ab4fa13e110f1e9a5ac2 100644 (file)
@@ -1,3 +1,8 @@
+2013-12-16  Jakub Jelinek  <jakub@redhat.com>
+
+       PR libgomp/58756
+       * testsuite/libgomp.c/pr58756.c: New test.
+
 2013-12-12  Jakub Jelinek  <jakub@redhat.com>
 
        PR libgomp/59467
diff --git a/libgomp/testsuite/libgomp.c/pr58756.c b/libgomp/testsuite/libgomp.c/pr58756.c
new file mode 100644 (file)
index 0000000..d35ea79
--- /dev/null
@@ -0,0 +1,58 @@
+/* PR libgomp/58756 */
+/* { dg-do run } */
+/* { dg-options "-O2" } */
+/* { dg-additional-options "-msse2" { target sse2_runtime } } */
+/* { dg-additional-options "-mavx" { target avx_runtime } } */
+
+extern void abort (void);
+int d[32 * 32];
+
+__attribute__((noinline, noclone)) int
+foo (int a, int b)
+{
+  int j, c = 0;
+  #pragma omp parallel for reduction(+: c)
+    for (j = 0; j < a; j += 32)
+      {
+       int l;
+       #pragma omp simd reduction(+: c) safelen(1)
+         for (l = 0; l < b; ++l)
+           c += d[j + l];
+      }
+  return c;
+}
+
+__attribute__((noinline, noclone)) int
+bar (int a)
+{
+  int j, c = 0;
+  #pragma omp parallel for simd reduction(+: c) safelen(1)
+    for (j = 0; j < a; ++j)
+      c += d[j];
+  return c;
+}
+
+__attribute__((noinline)) static int
+baz (int a)
+{
+  int j, c = 0;
+  #pragma omp simd reduction(+: c) safelen(1)
+    for (j = 0; j < a; ++j)
+      c += d[j];
+  return c;
+}
+
+int
+main ()
+{
+  int i;
+  for (i = 0; i < 32 * 32; i++)
+    d[i] = (i & 31);
+  if (foo (32 * 32, 32) != (31 * 32 / 2) * 32)
+    abort ();
+  if (bar (32 * 32) != (31 * 32 / 2) * 32)
+    abort ();
+  if (baz (32 * 32) != (31 * 32 / 2) * 32)
+    abort ();
+  return 0;
+}