This is the mail archive of the
gcc@gcc.gnu.org
mailing list for the GCC project.
Re: [PATCH] Re: ref_contains_indirect_ref always false?
- From: Richard Guenther <rguenther at suse dot de>
- To: Diego Novillo <dnovillo at redhat dot com>
- Cc: Richard Kenner <kenner at vlsi1 dot ultra dot nyu dot edu>,gcc-patches at gcc dot gnu dot org, gcc at gcc dot gnu dot org
- Date: Fri, 4 Nov 2005 17:34:18 +0100 (CET)
- Subject: Re: [PATCH] Re: ref_contains_indirect_ref always false?
- References: <10511041507.AA09327@vlsi1.ultra.nyu.edu> <200511041017.32255.dnovillo@redhat.com>
On Fri, 4 Nov 2005, Diego Novillo wrote:
> On Friday 04 November 2005 10:07, Richard Kenner wrote:
> > #if defined ENABLE_CHECKING
> > gcc_assert (handled_component_p (ref))
> > #endif
> >
> > If the comment says it has to be an ARRAY_REF, why not just check for
> > that?
>
> The comment is out of sync with the code. It's used in code that may be
> sending an arbitrary aggregate.
>
> Given that Dan asked to remove the call from tree-ssa-structalias.c, then
> we can take advantage and tighten the two predicates more.
>
> In ref_contains_indirect_ref:
> Rename to array_ref_contains_indirect_ref
> Add gcc_assert (TREE_CODE (ref) == ARRAY_REF) at the start.
>
> In ref_contains_array_ref:
> Leave the gcc_assert I proposed. That predicate is used for more than
> COMPONENT_REFs.
> The comment needs to be updated.
I bootstrapped and regtested the following on x86_64-unknown-linux-gnu.
Ok for mainline?
Thanks,
Richard.
2005-11-04 Richard Guenther <rguenther@suse.de>
* tree-flow.h (ref_contains_indirect_ref): Rename to
array_ref_contains_indirect_ref.
* tree-flow-inline.h (ref_contains_indirect_ref): Likewise.
(array_ref_contains_indirect_ref): Make comment match the code
and vice-versa.
(ref_contains_array_ref): Likewise.
* tree-ssa-structalias.c (find_func_aliases): Remove call to
ref_contains_indirect_ref.
* tree-ssa-loop-niter.c (infer_loop_bounds_from_undefined):
Rename calls to ref_contains_indirect_ref.
Index: tree-flow-inline.h
===================================================================
--- tree-flow-inline.h (revision 106485)
+++ tree-flow-inline.h (working copy)
@@ -1407,32 +1407,34 @@
return TREE_READONLY (var) && (TREE_STATIC (var) || DECL_EXTERNAL (var));
}
-/* Return true if REF, an ARRAY_REF, has an INDIRECT_REF somewhere in
- it. */
+/* Return true if REF, an ARRAY_REF, has an INDIRECT_REF somewhere in it. */
static inline bool
-ref_contains_indirect_ref (tree ref)
+array_ref_contains_indirect_ref (tree ref)
{
- while (handled_component_p (ref))
- {
- if (TREE_CODE (ref) == INDIRECT_REF)
- return true;
- ref = TREE_OPERAND (ref, 0);
- }
- return false;
+ gcc_assert (TREE_CODE (ref) == ARRAY_REF);
+
+ do {
+ ref = TREE_OPERAND (ref, 0);
+ } while (handled_component_p (ref));
+
+ return TREE_CODE (ref) == INDIRECT_REF;
}
-/* Return true if REF, a COMPONENT_REF, has an ARRAY_REF somewhere in it. */
+/* Return true if REF, a handled component reference, has an ARRAY_REF
+ somewhere in it. */
static inline bool
ref_contains_array_ref (tree ref)
{
- while (handled_component_p (ref))
- {
- if (TREE_CODE (ref) == ARRAY_REF)
- return true;
- ref = TREE_OPERAND (ref, 0);
- }
+ gcc_assert (handled_component_p (ref));
+
+ do {
+ if (TREE_CODE (ref) == ARRAY_REF)
+ return true;
+ ref = TREE_OPERAND (ref, 0);
+ } while (handled_component_p (ref));
+
return false;
}
Index: tree-flow.h
===================================================================
--- tree-flow.h (revision 106485)
+++ tree-flow.h (working copy)
@@ -614,7 +614,7 @@
static inline subvar_t get_subvars_for_var (tree);
static inline tree get_subvar_at (tree, unsigned HOST_WIDE_INT);
static inline bool ref_contains_array_ref (tree);
-static inline bool ref_contains_indirect_ref (tree);
+static inline bool array_ref_contains_indirect_ref (tree);
extern tree okay_component_ref_for_subvars (tree, unsigned HOST_WIDE_INT *,
unsigned HOST_WIDE_INT *);
static inline bool var_can_have_subvars (tree);
Index: tree-ssa-structalias.c
===================================================================
--- tree-ssa-structalias.c (revision 106485)
+++ tree-ssa-structalias.c (working copy)
@@ -2865,7 +2865,6 @@
containing pointers, dereferences, and call expressions. */
if (POINTER_TYPE_P (TREE_TYPE (lhsop))
|| AGGREGATE_TYPE_P (TREE_TYPE (lhsop))
- || ref_contains_indirect_ref (lhsop)
|| TREE_CODE (rhsop) == CALL_EXPR)
{
lhs = get_constraint_for (lhsop, NULL);
Index: tree-ssa-loop-niter.c
===================================================================
--- tree-ssa-loop-niter.c (revision 106485)
+++ tree-ssa-loop-niter.c (working copy)
@@ -1438,11 +1438,11 @@
/* For each array access, analyze its access function
and record a bound on the loop iteration domain. */
if (TREE_CODE (op1) == ARRAY_REF
- && !ref_contains_indirect_ref (op1))
+ && !array_ref_contains_indirect_ref (op1))
estimate_iters_using_array (stmt, op1);
if (TREE_CODE (op0) == ARRAY_REF
- && !ref_contains_indirect_ref (op0))
+ && !array_ref_contains_indirect_ref (op0))
estimate_iters_using_array (stmt, op0);
/* For each signed type variable in LOOP, analyze its
@@ -1494,7 +1494,7 @@
for (args = TREE_OPERAND (stmt, 1); args;
args = TREE_CHAIN (args))
if (TREE_CODE (TREE_VALUE (args)) == ARRAY_REF
- && !ref_contains_indirect_ref (TREE_VALUE (args)))
+ && !array_ref_contains_indirect_ref (TREE_VALUE (args)))
estimate_iters_using_array (stmt, TREE_VALUE (args));
break;