aboutsummaryrefslogtreecommitdiff
path: root/gcc
diff options
context:
space:
mode:
authorJakub Jelinek <jakub@redhat.com>2018-07-17 10:06:25 +0200
committerJakub Jelinek <jakub@gcc.gnu.org>2018-07-17 10:06:25 +0200
commit3a10621137037719a99c2e5b75ec2e20c891ad59 (patch)
tree2f092e709ef9b302a3dcc0c2bdceac26a03a0476 /gcc
parent980f94b75b8ccd47afa55c6109a5899f325a61ee (diff)
downloadgcc-3a10621137037719a99c2e5b75ec2e20c891ad59.zip
gcc-3a10621137037719a99c2e5b75ec2e20c891ad59.tar.gz
gcc-3a10621137037719a99c2e5b75ec2e20c891ad59.tar.bz2
re PR middle-end/86539 (OpenMP wrong-code with taskloop and references)
PR middle-end/86539 * gimplify.c (gimplify_omp_for): Ensure taskloop firstprivatized init and cond temporaries don't have reference type if iterator has pointer type. For init use &for_pre_body instead of pre_p if for_pre_body is non-empty. * testsuite/libgomp.c++/pr86539.C: New test. From-SVN: r262776
Diffstat (limited to 'gcc')
-rw-r--r--gcc/ChangeLog8
-rw-r--r--gcc/gimplify.c34
2 files changed, 41 insertions, 1 deletions
diff --git a/gcc/ChangeLog b/gcc/ChangeLog
index 6bdf930..64aab92 100644
--- a/gcc/ChangeLog
+++ b/gcc/ChangeLog
@@ -1,3 +1,11 @@
+2018-07-17 Jakub Jelinek <jakub@redhat.com>
+
+ PR middle-end/86539
+ * gimplify.c (gimplify_omp_for): Ensure taskloop firstprivatized init
+ and cond temporaries don't have reference type if iterator has
+ pointer type. For init use &for_pre_body instead of pre_p if
+ for_pre_body is non-empty.
+
2018-07-16 Segher Boessenkool <segher@kernel.crashing.org>
* config/rs6000/rs6000.md (trunc<mode>sf2): Expand truncates of
diff --git a/gcc/gimplify.c b/gcc/gimplify.c
index 6b76d17..4a109ae 100644
--- a/gcc/gimplify.c
+++ b/gcc/gimplify.c
@@ -9811,9 +9811,26 @@ gimplify_omp_for (tree *expr_p, gimple_seq *pre_p)
t = TREE_VEC_ELT (OMP_FOR_INIT (for_stmt), i);
if (!is_gimple_constant (TREE_OPERAND (t, 1)))
{
+ tree type = TREE_TYPE (TREE_OPERAND (t, 0));
TREE_OPERAND (t, 1)
= get_initialized_tmp_var (TREE_OPERAND (t, 1),
- pre_p, NULL, false);
+ gimple_seq_empty_p (for_pre_body)
+ ? pre_p : &for_pre_body, NULL,
+ false);
+ /* Reference to pointer conversion is considered useless,
+ but is significant for firstprivate clause. Force it
+ here. */
+ if (TREE_CODE (type) == POINTER_TYPE
+ && (TREE_CODE (TREE_TYPE (TREE_OPERAND (t, 1)))
+ == REFERENCE_TYPE))
+ {
+ tree v = create_tmp_var (TYPE_MAIN_VARIANT (type));
+ tree m = build2 (INIT_EXPR, TREE_TYPE (v), v,
+ TREE_OPERAND (t, 1));
+ gimplify_and_add (m, gimple_seq_empty_p (for_pre_body)
+ ? pre_p : &for_pre_body);
+ TREE_OPERAND (t, 1) = v;
+ }
tree c = build_omp_clause (input_location,
OMP_CLAUSE_FIRSTPRIVATE);
OMP_CLAUSE_DECL (c) = TREE_OPERAND (t, 1);
@@ -9825,11 +9842,26 @@ gimplify_omp_for (tree *expr_p, gimple_seq *pre_p)
t = TREE_VEC_ELT (OMP_FOR_COND (for_stmt), i);
if (!is_gimple_constant (TREE_OPERAND (t, 1)))
{
+ tree type = TREE_TYPE (TREE_OPERAND (t, 0));
TREE_OPERAND (t, 1)
= get_initialized_tmp_var (TREE_OPERAND (t, 1),
gimple_seq_empty_p (for_pre_body)
? pre_p : &for_pre_body, NULL,
false);
+ /* Reference to pointer conversion is considered useless,
+ but is significant for firstprivate clause. Force it
+ here. */
+ if (TREE_CODE (type) == POINTER_TYPE
+ && (TREE_CODE (TREE_TYPE (TREE_OPERAND (t, 1)))
+ == REFERENCE_TYPE))
+ {
+ tree v = create_tmp_var (TYPE_MAIN_VARIANT (type));
+ tree m = build2 (INIT_EXPR, TREE_TYPE (v), v,
+ TREE_OPERAND (t, 1));
+ gimplify_and_add (m, gimple_seq_empty_p (for_pre_body)
+ ? pre_p : &for_pre_body);
+ TREE_OPERAND (t, 1) = v;
+ }
tree c = build_omp_clause (input_location,
OMP_CLAUSE_FIRSTPRIVATE);
OMP_CLAUSE_DECL (c) = TREE_OPERAND (t, 1);