This is the mail archive of the
gcc-patches@gcc.gnu.org
mailing list for the GCC project.
Re: [PATCH] Fix inliner INDIRECT_EXPR <ADDR_EXPR> handling (PR c/34668)
On Jan 10, 2008 12:26 PM, Jakub Jelinek <jakub@redhat.com> wrote:
> On Thu, Jan 10, 2008 at 11:43:34AM +0100, Richard Guenther wrote:
> > On Jan 10, 2008 10:04 AM, Jakub Jelinek <jakub@redhat.com> wrote:
> > I don't think so. The code should read
> >
> > /* *(foo *)&fooarray => fooarray[0] */
> > else if (TREE_CODE (optype) == ARRAY_TYPE
> > && useless_type_conversion_p (type, TREE_TYPE (optype)))
> > {
> > tree type_domain = TYPE_DOMAIN (optype);
> > tree min_val = size_zero_node;
> > if (type_domain && TYPE_MIN_VALUE (type_domain))
> > min_val = TYPE_MIN_VALUE (type_domain);
> > return build4 (ARRAY_REF, TREE_TYPE (optype), op, min_val, NULL_TREE, NULL_TREE);
> > }
> >
> > and similar in fold_indirect_ref_rhs - where it already _does_ look like that.
> >
> > Would this fix it?
>
> In fold-const.c? Isn't useless_type_conversion_p a GIMPLE thing,
> but fold-const.c is used also by the frontends? Certainly
> useless_type_conversion_p isn't ever used in fold-const.c ATM, nor
> it includes tree-flow.h, which IMHO says something.
Oh, right.
> Using fold_indirect_ref_rhs (after exporting it) works for this testcase,
> so if that's your preference we could do that. Perhaps the complex and
> vector cases I mentioned are non-issue, the types could very well be shared,
> will investigate.
fold_indirect_ref_rhs may not be applied to a lhs of a stmt, so if this is
assured in copy_body_r, this should work.
Richard.