From 1fefbb66c8282a4d9e74dc178a3578e4c302862f Mon Sep 17 00:00:00 2001 From: Richard Biener Date: Thu, 24 Sep 2015 07:35:55 +0000 Subject: [PATCH] tree-ssa-sccvn.h (vn_reference_op_struct): Add clique and base members. 2015-09-24 Richard Biener * tree-ssa-sccvn.h (vn_reference_op_struct): Add clique and base members. * tree-ssa-sccvn.c (copy_reference_ops_from_ref): Record clique and base for MEM_REF and TARGET_MEM_REF. Handle BIT_FIELD_REF offset. (ao_ref_init_from_vn_reference): Record clique and base in the built base. * tree-ssa-pre.c (create_component_ref_by_pieces_1): Likewise * g++.dg/tree-ssa/restrict3.C: New testcase. From-SVN: r228074 --- gcc/ChangeLog | 11 +++++++++++ gcc/testsuite/ChangeLog | 4 ++++ gcc/testsuite/g++.dg/tree-ssa/restrict3.C | 12 ++++++++++++ gcc/tree-ssa-pre.c | 13 ++++++++++--- gcc/tree-ssa-sccvn.c | 12 ++++++++++++ gcc/tree-ssa-sccvn.h | 3 +++ 6 files changed, 52 insertions(+), 3 deletions(-) create mode 100644 gcc/testsuite/g++.dg/tree-ssa/restrict3.C diff --git a/gcc/ChangeLog b/gcc/ChangeLog index 5ae3e4436af..8481677df62 100644 --- a/gcc/ChangeLog +++ b/gcc/ChangeLog @@ -1,3 +1,14 @@ +2015-09-24 Richard Biener + + * tree-ssa-sccvn.h (vn_reference_op_struct): Add clique and base + members. + * tree-ssa-sccvn.c (copy_reference_ops_from_ref): Record clique + and base for MEM_REF and TARGET_MEM_REF. Handle BIT_FIELD_REF + offset. + (ao_ref_init_from_vn_reference): Record clique and base in the + built base. + * tree-ssa-pre.c (create_component_ref_by_pieces_1): Likewise + 2015-09-24 Richard Biener PR tree-optimization/48885 diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog index 1d9b87273e9..c9ffa70d5ad 100644 --- a/gcc/testsuite/ChangeLog +++ b/gcc/testsuite/ChangeLog @@ -1,3 +1,7 @@ +2015-09-24 Richard Biener + + * g++.dg/tree-ssa/restrict3.C: New testcase. + 2015-09-24 Richard Biener PR tree-optimization/48885 diff --git a/gcc/testsuite/g++.dg/tree-ssa/restrict3.C b/gcc/testsuite/g++.dg/tree-ssa/restrict3.C new file mode 100644 index 00000000000..d1e1343a7ce --- /dev/null +++ b/gcc/testsuite/g++.dg/tree-ssa/restrict3.C @@ -0,0 +1,12 @@ +// { dg-do compile } +// { dg-options "-O -fdump-tree-fre1" } + +int +f (int *__restrict__ &__restrict__ p, int *p2) +{ + *p = 1; + *p2 = 2; + return *p; +} + +// { dg-final { scan-tree-dump "return 1;" "fre1" } } diff --git a/gcc/tree-ssa-pre.c b/gcc/tree-ssa-pre.c index 56bc7bf1492..ac298d3cabd 100644 --- a/gcc/tree-ssa-pre.c +++ b/gcc/tree-ssa-pre.c @@ -2531,7 +2531,10 @@ create_component_ref_by_pieces_1 (basic_block block, vn_reference_t ref, off)); baseop = build_fold_addr_expr (base); } - return fold_build2 (MEM_REF, currop->type, baseop, offset); + genop = build2 (MEM_REF, currop->type, baseop, offset); + MR_DEPENDENCE_CLIQUE (genop) = currop->clique; + MR_DEPENDENCE_BASE (genop) = currop->base; + return genop; } case TARGET_MEM_REF: @@ -2554,8 +2557,12 @@ create_component_ref_by_pieces_1 (basic_block block, vn_reference_t ref, if (!genop1) return NULL_TREE; } - return build5 (TARGET_MEM_REF, currop->type, - baseop, currop->op2, genop0, currop->op1, genop1); + genop = build5 (TARGET_MEM_REF, currop->type, + baseop, currop->op2, genop0, currop->op1, genop1); + + MR_DEPENDENCE_CLIQUE (genop) = currop->clique; + MR_DEPENDENCE_BASE (genop) = currop->base; + return genop; } case ADDR_EXPR: diff --git a/gcc/tree-ssa-sccvn.c b/gcc/tree-ssa-sccvn.c index 18529aca432..57c1b55a4a6 100644 --- a/gcc/tree-ssa-sccvn.c +++ b/gcc/tree-ssa-sccvn.c @@ -773,6 +773,8 @@ copy_reference_ops_from_ref (tree ref, vec *result) temp.op1 = TMR_STEP (ref); temp.op2 = TMR_OFFSET (ref); temp.off = -1; + temp.clique = MR_DEPENDENCE_CLIQUE (ref); + temp.base = MR_DEPENDENCE_BASE (ref); result->quick_push (temp); memset (&temp, 0, sizeof (temp)); @@ -816,11 +818,19 @@ copy_reference_ops_from_ref (tree ref, vec *result) temp.op0 = TREE_OPERAND (ref, 1); if (tree_fits_shwi_p (TREE_OPERAND (ref, 1))) temp.off = tree_to_shwi (TREE_OPERAND (ref, 1)); + temp.clique = MR_DEPENDENCE_CLIQUE (ref); + temp.base = MR_DEPENDENCE_BASE (ref); break; case BIT_FIELD_REF: /* Record bits and position. */ temp.op0 = TREE_OPERAND (ref, 1); temp.op1 = TREE_OPERAND (ref, 2); + if (tree_fits_shwi_p (TREE_OPERAND (ref, 2))) + { + HOST_WIDE_INT off = tree_to_shwi (TREE_OPERAND (ref, 2)); + if (off % BITS_PER_UNIT == 0) + temp.off = off / BITS_PER_UNIT; + } break; case COMPONENT_REF: /* The field decl is enough to unambiguously specify the field, @@ -1017,6 +1027,8 @@ ao_ref_init_from_vn_reference (ao_ref *ref, base_alias_set = get_deref_alias_set (op->op0); *op0_p = build2 (MEM_REF, op->type, NULL_TREE, op->op0); + MR_DEPENDENCE_CLIQUE (*op0_p) = op->clique; + MR_DEPENDENCE_BASE (*op0_p) = op->base; op0_p = &TREE_OPERAND (*op0_p, 0); break; diff --git a/gcc/tree-ssa-sccvn.h b/gcc/tree-ssa-sccvn.h index e3dddee0df1..92ca85ab8be 100644 --- a/gcc/tree-ssa-sccvn.h +++ b/gcc/tree-ssa-sccvn.h @@ -83,6 +83,9 @@ typedef struct vn_reference_op_struct ENUM_BITFIELD(tree_code) opcode : 16; /* 1 for instrumented calls. */ unsigned with_bounds : 1; + /* Dependence info, used for [TARGET_]MEM_REF only. */ + unsigned short clique; + unsigned short base; /* Constant offset this op adds or -1 if it is variable. */ HOST_WIDE_INT off; tree type; -- 2.30.2