This is the mail archive of the
gcc-patches@gcc.gnu.org
mailing list for the GCC project.
Re: [PATCH] Fix PR35607, another revenge of invariant addresses (ivopts)
Hi,
> > > > Yes. address_invariant_p should be simply
> > >
> > > Like that one.
> > >
> > > Can we rely on TREE_INVARIANT on the base object of the reference
> > > tree or shall we open-code that as well (hm, I wasn't able to
> > > quickly come up with the correct thing here ;)).
> > >
> > > + return TREE_INVARIANT (op);
> >
> > return CONSTANT_CLASS_P (op) || DECL_P (op);
>
> Actually recompute_tree_invariant_for_addr_expr uses the equivalent of
>
> if (DECL_P (op)
> && (staticp (op)
> || decl_function_context (op) == current_function_decl
> || (TREE_CODE (op) == VAR_DECL
> && DECL_THREAD_LOCAL_P (op))))
> return true;
>
> return CONSTANT_CLASS_P (op);
>
> so not all DECLs are invariant in the old sense. Though I don't see
> why we shouldn't allow arbitrary DECLs here...
with code like
void foo(int n)
{
int j, k;
for (k = 1; k < n; k++)
{
int blah[k];
for (j = 0; j < k; j++)
{
int t;
bar (blah, &t)
}
}
}
&t probably is not invariant in the function. So
decl_function_context (op) == current_function_decl does seem to make
sense. Let's just copy the condition from
recompute_tree_invariant_for_addr_expr, that should be safe.
Zdenek
- References:
- Re: [PATCH] Fix PR35607, another revenge of invariant addresses (ivopts)
- Re: [PATCH] Fix PR35607, another revenge of invariant addresses (ivopts)
- Re: [PATCH] Fix PR35607, another revenge of invariant addresses (ivopts)
- Re: [PATCH] Fix PR35607, another revenge of invariant addresses (ivopts)
- Re: [PATCH] Fix PR35607, another revenge of invariant addresses (ivopts)
- Re: [PATCH] Fix PR35607, another revenge of invariant addresses (ivopts)
- Re: [PATCH] Fix PR35607, another revenge of invariant addresses (ivopts)
- Re: [PATCH] Fix PR35607, another revenge of invariant addresses (ivopts)
- Re: [PATCH] Fix PR35607, another revenge of invariant addresses (ivopts)
- Re: [PATCH] Fix PR35607, another revenge of invariant addresses (ivopts)