public inbox for gcc-patches@gcc.gnu.org
 help / color / mirror / Atom feed
From: Richard Biener <richard.guenther@gmail.com>
To: Martin Sebor <msebor@gmail.com>
Cc: Jakub Jelinek <jakub@redhat.com>, gcc-patches <gcc-patches@gcc.gnu.org>
Subject: Re: [PATCH] include MEM_REF type in tree dumps (PR 90676)
Date: Tue, 11 Jun 2019 10:43:00 -0000	[thread overview]
Message-ID: <CAFiYyc2hRh=xeFMtYQjXXzVnD28nKUnC7ghnY4Msu_6N88P_xg@mail.gmail.com> (raw)
In-Reply-To: <f89f44c6-f7fc-e82e-c59d-b3170e453368@gmail.com>

On Mon, Jun 10, 2019 at 10:37 PM Martin Sebor <msebor@gmail.com> wrote:
>
> On 6/10/19 1:29 PM, Jakub Jelinek wrote:
> > On Mon, Jun 10, 2019 at 01:23:28PM -0600, Martin Sebor wrote:
> >> +  else if (integer_zerop (TREE_OPERAND (node, 1))
> >> +       /* Dump the types of INTEGER_CSTs explicitly, for we can't
> >> +          infer them and MEM_ATTR caching will share MEM_REFs
> >> +          with differently-typed op0s.  */
> >> +       && TREE_CODE (TREE_OPERAND (node, 0)) != INTEGER_CST
> >> +       /* Released SSA_NAMES have no TREE_TYPE.  */
> >> +       && TREE_TYPE (TREE_OPERAND (node, 0)) != NULL_TREE
> >> +       /* Same pointer types, but ignoring POINTER_TYPE vs.
> >> +          REFERENCE_TYPE.  */
> >> +       && (TREE_TYPE (TREE_TYPE (TREE_OPERAND (node, 0)))
> >> +           == TREE_TYPE (TREE_TYPE (TREE_OPERAND (node, 1))))
> >> +       && (TYPE_MODE (TREE_TYPE (TREE_OPERAND (node, 0)))
> >> +           == TYPE_MODE (TREE_TYPE (TREE_OPERAND (node, 1))))
> >> +       && (TYPE_REF_CAN_ALIAS_ALL (TREE_TYPE (TREE_OPERAND (node, 0)))
> >> +           == TYPE_REF_CAN_ALIAS_ALL (TREE_TYPE (TREE_OPERAND (node, 1))))
> >> +       /* Same value types ignoring qualifiers.  */
> >> +       && (TYPE_MAIN_VARIANT (TREE_TYPE (node))
> >> +           == TYPE_MAIN_VARIANT
> >> +           (TREE_TYPE (TREE_TYPE (TREE_OPERAND (node, 1)))))
> >
> > You should be using types_compatible_p rather than type equality, that is
> > all GIMPLE cares about.
>
> The code above predates my change, I just factored it out into
> a separate function; it does make the diff bigger.  The code
> I introduced only adds the <...> if the size of the access
> differs from the size of the operand. I used type sizes rather
> than testing their compatibility to minimize the number of tests
> that might need updating.
>
> This is the salient bit:
>
> +      pp_string (pp, "MEM");
> +
> +      tree nodetype = TREE_TYPE (node);
> +      tree op0 = TREE_OPERAND (node, 0);
> +      tree op1 = TREE_OPERAND (node, 1);
> +      tree op1type = TYPE_MAIN_VARIANT (TREE_TYPE (op1));
> +
> +      if (!tree_int_cst_equal (TYPE_SIZE (nodetype),
> +                              TYPE_SIZE (TREE_TYPE (op1type))))
> +       {
> +         pp_string (pp, " <");
> +         /* If the size of the type of the operand is not the same
> +            as the size of the MEM_REF expression include the type
> +            of the latter similar to the TDF_GIMPLE output to make
> +            it clear how many bytes of memory are being accessed.  */
> +         dump_generic_node (pp, nodetype, spc, flags | TDF_SLIM, false);
> +         pp_string (pp, "> ");
> +       }

You need to guard against non-constant TYPE_SIZE here (for both
involved types) so I suggest you use operand_equal_p (..., 0).  If you
do that you need to guard against NULL_TREE TYPE_SIZE
(tree_int_cst_equal handled that as unequal).

OK with such change.
Richard.

> Martin

  reply	other threads:[~2019-06-11 10:43 UTC|newest]

Thread overview: 23+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-06-01 15:53 Martin Sebor
2019-06-01 16:16 ` Martin Sebor
2019-06-03  8:36 ` Richard Biener
2019-06-03  8:57   ` Jakub Jelinek
2019-06-03 10:35     ` Richard Biener
2019-06-03 15:13       ` Martin Sebor
2019-06-04 10:58         ` Richard Biener
2019-06-10 19:23           ` Martin Sebor
2019-06-10 19:29             ` Jakub Jelinek
2019-06-10 20:37               ` Martin Sebor
2019-06-11 10:43                 ` Richard Biener [this message]
2019-06-12 21:34                   ` Rainer Orth
2019-06-12 21:47                     ` Martin Sebor
2019-06-13  9:04                       ` Rainer Orth
2019-06-13 10:45                         ` Jakub Jelinek
2019-06-13 11:18                           ` Richard Biener
2019-06-13 11:18                           ` Rainer Orth
2019-06-13 15:30                           ` Martin Sebor
2019-06-13 15:34                             ` Jakub Jelinek
2019-06-13 15:50                               ` Martin Sebor
2019-06-13 15:54                                 ` Jakub Jelinek
2019-06-14  7:44                                   ` Richard Biener
2019-06-14  8:51                                     ` Jan Hubicka

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to='CAFiYyc2hRh=xeFMtYQjXXzVnD28nKUnC7ghnY4Msu_6N88P_xg@mail.gmail.com' \
    --to=richard.guenther@gmail.com \
    --cc=gcc-patches@gcc.gnu.org \
    --cc=jakub@redhat.com \
    --cc=msebor@gmail.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).