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: gcc-patches <gcc-patches@gcc.gnu.org>
Subject: Re: [PATCH] include MEM_REF type in tree dumps (PR 90676)
Date: Mon, 03 Jun 2019 08:36:00 -0000	[thread overview]
Message-ID: <CAFiYyc07vnZE0MH=a52Hz-4e+=ufEMbdPmmBWz=DLA0zaFt3Bg@mail.gmail.com> (raw)
In-Reply-To: <ecf4c116-9697-71c7-c04f-d563b8c1f64d@gmail.com>

On Sat, Jun 1, 2019 at 5:53 PM Martin Sebor <msebor@gmail.com> wrote:
>
> I spent a bunch of time the other day trying to understand why
> the second of the two assignments below to a char array was
> apparently not being done by trunk
>
>    a[0] = 1;
>    a[1] = 0;
>
> The optimized GIMPLE dump simply shows:
>
>    MEM[(char *)&a] = 1;
>
> when in the past it showed:
>
>    MEM[(char[2] *)&a2] = 1;
>
> After some debugging I figured out that this is the result of
> the store merging pass transforming the two assignments into
> one:
>
>    *(short int *)a = 1;
>
> and the MEM_REF dump mentioning only the type of the second
> operand and not the type of the access.
>
> To avoid this confusion the attached patch adds to the dump
> a cast to the MEM_REF type for accesses whose size is not equal
> to the size of the operand (when the sizes are the same no new
> cast is prepended).  The effect is that with store merging in
> effect, the dump for the above becomes
>
>    MEM[(short int *)(char *)&a] = 1;

I think this is confusing syntax.  Iff you absolutely refuse to
make the -gimple dump the default for MEM_REF and you insist
on fixing this issue then please follow how we dump VIEW_CONVERT_EXPR
which is the only other tree code we dump the access type, thus

 MEM<short int *>[(char *)&a] = 1;

btw, -gimple (iff only applied to MEM_REF) would have dumped

 __MEM <short int, 8> ((char *)&a2) = 1;

also including the effective alignment of the access.  Your variant
suggests that the alignment is that of short int which is wrong.

Yes, there's testsuite fallout I guess mostly about () vs. [] and spacing
(the GIMPLE FE doesn't insist on spacing before/after <>).

So please do not change MEM_REF dumping in this way.

Richard.

> This should make both the size and the type of the access clear
> and help avoid the confusion.  The output isn't the same as in
> earlier releases because because the access really is done via
> a short pointer and not as an array of char.
>
> There is more detail in MEM_REF that could be included here but
> it seems that the size of the access is essential to interpreting
> the dumps.
>
> Tested on x86_64-linux with only minimal testsuite fallout.
>
> Martin

  parent reply	other threads:[~2019-06-03  8:36 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 [this message]
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
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                           ` Rainer Orth
2019-06-13 11:18                           ` Richard Biener
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='CAFiYyc07vnZE0MH=a52Hz-4e+=ufEMbdPmmBWz=DLA0zaFt3Bg@mail.gmail.com' \
    --to=richard.guenther@gmail.com \
    --cc=gcc-patches@gcc.gnu.org \
    --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).