Hi! The following testcase FAILs, because the UDR combiner is invoked incorrectly. lower_omp_rec_clauses expects that when it sets DECL_VALUE_EXPR/DECL_HAS_VALUE_EXPR_P for both the placeholder and the var that everything will be properly regimplified, but as the variable in question is a PARM_DECL rather than VAR_DECL, lower_omp_regimplify_p doesn't say that it should be regimplified and so it is not.
Bootstrapped/regtested on x86_64-linux and i686-linux, committed to trunk so far. 2021-06-22 Jakub Jelinek <ja...@redhat.com> PR middle-end/101167 * omp-low.c (lower_omp_regimplify_p): Regimplify also PARM_DECLs and RESULT_DECLs that have DECL_HAS_VALUE_EXPR_P set. * testsuite/libgomp.c-c++-common/task-reduction-15.c: New test. --- gcc/omp-low.c.jj 2021-06-22 12:31:29.753251003 +0200 +++ gcc/omp-low.c 2021-06-22 19:24:11.955419382 +0200 @@ -13682,7 +13682,9 @@ lower_omp_regimplify_p (tree *tp, int *w tree t = *tp; /* Any variable with DECL_VALUE_EXPR needs to be regimplified. */ - if (VAR_P (t) && data == NULL && DECL_HAS_VALUE_EXPR_P (t)) + if ((VAR_P (t) || TREE_CODE (t) == PARM_DECL || TREE_CODE (t) == RESULT_DECL) + && data == NULL + && DECL_HAS_VALUE_EXPR_P (t)) return t; if (task_shared_vars --- libgomp/testsuite/libgomp.c-c++-common/task-reduction-15.c.jj 2021-06-22 19:43:40.970141134 +0200 +++ libgomp/testsuite/libgomp.c-c++-common/task-reduction-15.c 2021-06-22 19:43:32.295252461 +0200 @@ -0,0 +1,61 @@ +/* PR middle-end/101167 */ + +extern +#ifdef __cplusplus +"C" +#endif +void abort (void); + +struct S { int a, b, c[2]; }; + +void +init (struct S *x) +{ + x->a = 0; + x->b = 0; + x->c[0] = 0; + x->c[1] = 0; +} + +void +merge (struct S *x, struct S *y) +{ + x->a += y->a; + x->b += y->b; +} + +#pragma omp declare reduction (+: struct S : merge (&omp_out, &omp_in)) initializer (init (&omp_priv)) + +void +foo (struct S x) +{ + #pragma omp taskgroup task_reduction (+: x) + { + #pragma omp task in_reduction (+: x) + { + x.a++; + x.b++; + } + #pragma omp task in_reduction (+: x) + { + x.a += 4; + x.b += 14; + } + #pragma omp task in_reduction (+: x) + { + x.a += 9; + x.b += 19; + } + } + if (x.a != 56 || x.b != 86) + abort (); +} + +int +main () +{ + struct S x = { 42, 52 }; + #pragma omp parallel master num_threads(3) + foo (x); + return 0; +} Jakub