diff options
Diffstat (limited to 'gcc/omp-low.c')
| -rw-r--r-- | gcc/omp-low.c | 15 |
1 files changed, 12 insertions, 3 deletions
diff --git a/gcc/omp-low.c b/gcc/omp-low.c index 678c36e..3f7debf 100644 --- a/gcc/omp-low.c +++ b/gcc/omp-low.c @@ -5660,10 +5660,19 @@ lower_oacc_reductions (location_t loc, tree clauses, tree level, bool inner, outgoing = var; incoming = omp_reduction_init_op (loc, rcode, type); } - else if (ctx->outer) - incoming = outgoing = lookup_decl (orig, ctx->outer); else - incoming = outgoing = orig; + { + /* Try to look at enclosing contexts for reduction var, + use original if no mapping found. */ + tree t = NULL_TREE; + omp_context *c = ctx->outer; + while (c && !t) + { + t = maybe_lookup_decl (orig, c); + c = c->outer; + } + incoming = outgoing = (t ? t : orig); + } has_outer_reduction:; } |
