@@ -1,3 +1,8 @@
+2014-10-23 Thomas Schwinge <thomas@codesourcery.com>
+
+ * omp-low.c (finalize_reduction_data): Don't skip the reduction
+ variable's original value.
+
2014-10-20 Cesar Philippidis <cesar@codesourcery.com>
* gimplify.c (gimplify_scan_omp_clauses): Remove switch stmt which
@@ -9869,8 +9869,7 @@ finalize_reduction_data (tree clauses, tree nthreads, gimple_seq *stmt_seqp,
let var = the original reduction variable
let array = reduction variable array
- var = array[0]
- for (i = 1; i < nthreads; i++)
+ for (i = 0; i < nthreads; i++)
var op= array[i]
*/
@@ -9878,42 +9877,9 @@ finalize_reduction_data (tree clauses, tree nthreads, gimple_seq *stmt_seqp,
loop_body = create_artificial_label (UNKNOWN_LOCATION);
loop_exit = create_artificial_label (UNKNOWN_LOCATION);
- /* Initialize the reduction variables to be value of the first array
- element. */
- for (c = clauses; c; c = OMP_CLAUSE_CHAIN (c))
- {
- if (OMP_CLAUSE_CODE (c) != OMP_CLAUSE_REDUCTION)
- continue;
-
- tree_code reduction_code = OMP_CLAUSE_REDUCTION_CODE (c);
-
- /* reduction(-:var) sums up the partial results, so it acts
- identically to reduction(+:var). */
- if (reduction_code == MINUS_EXPR)
- reduction_code = PLUS_EXPR;
-
- /* Set up reduction variable, var. Becuase it's not gimple register,
- it needs to be treated as a reference. */
- var = OMP_CLAUSE_DECL (c);
- type = get_base_type (var);
- tree ptr = lookup_reduction (omp_get_id (OMP_CLAUSE_DECL (c)), ctx);
-
- /* Extract array[0] into mem. */
- tree mem = create_tmp_var (type, NULL);
- gimplify_assign (mem, build_simple_mem_ref (ptr), stmt_seqp);
-
- /* Find the original reduction variable. */
- tree x = build_outer_var_ref (var, ctx);
- if (is_reference (var))
- var = build_simple_mem_ref (var);
-
- x = lang_hooks.decls.omp_clause_assign_op (c, var, mem);
- gimplify_and_add (unshare_expr(x), stmt_seqp);
- }
-
- /* Create an index variable and set it to one. */
+ /* Create and initialize an index variable. */
tree ix = create_tmp_var (sizetype, NULL);
- gimplify_assign (ix, fold_build1 (NOP_EXPR, sizetype, integer_one_node),
+ gimplify_assign (ix, fold_build1 (NOP_EXPR, sizetype, integer_zero_node),
stmt_seqp);
/* Insert the loop header label here. */
@@ -1,3 +1,7 @@
+2014-10-23 Thomas Schwinge <thomas@codesourcery.com>
+
+ * testsuite/libgomp.oacc-c/reduction-initial-1.c: New file.
+
2014-10-20 Cesar Philippidis <cesar@codesourcery.com>
* (GOACC_update): Declare.
new file mode 100644
@@ -0,0 +1,32 @@
+/* { dg-do run } */
+/* TODO:
+ { dg-xfail-run-if "" { *-*-* } { "-DACC_DEVICE_TYPE_host=1" } { "" } } */
+
+int
+main(void)
+{
+#define I 5
+/* TODO */
+#ifdef ACC_DEVICE_TYPE_host_nonshm
+# define N 1
+#else
+# define N 11
+#endif
+#define A 8
+
+ int a = A;
+ int s = I;
+
+#pragma acc parallel vector_length(N)
+ {
+ int i;
+#pragma acc loop reduction(+:s)
+ for (i = 0; i < N; ++i)
+ s += a;
+ }
+
+ if (s != I + N * A)
+ __builtin_abort();
+
+ return 0;
+}