public inbox for gcc@gcc.gnu.org
 help / color / mirror / Atom feed
From: Jim Wilson <jimw@sifive.com>
To: Paulo Matos <pmatos@linki.tools>, "gcc@gcc.gnu.org" <gcc@gcc.gnu.org>
Subject: Re: riscv64 dep. computation
Date: Thu, 14 Feb 2019 18:56:00 -0000	[thread overview]
Message-ID: <e64251a9-5f2d-aacc-5666-03c8dba622f7@sifive.com> (raw)
In-Reply-To: <2892345b-53af-73f7-35f0-af68708fb843@linki.tools>

On 2/14/19 3:13 AM, Paulo Matos wrote:
> If I compile this with -O2, sched1 groups all loads and all stores
> together. That's perfect. However, if I change TYPE to unsigned char and
> recompile, the stores and loads are interleaved.
> 
> Further investigation shows that for unsigned char there are extra
> dependencies that block the scheduler from grouping stores and loads.

The ISO C standard says that anything can be casted to char *, and char 
* can be casted to anything.  Hence, a char * pointer aliases everything.

If you look at the alias set info in the MEMs, you can see that the char 
* references are in alias set 0, which means that they alias everything. 
  The short * references are in alias set 2 which means they only alias 
other stuff in alias set 2.  The difference here is that short * does 
not alias the structure pointers, but char * does.  I haven't tried 
debugging your example, but this is presumably where the difference 
comes from.

Because x and y are pointer parameters, the compiler must assume that 
they might alias.  And because char * aliases everything, the char 
references alias them too.  If you change x and y to global variables, 
then they no longer alias each other, and the compiler will schedule all 
of the loads first, even for char.

Jim

  reply	other threads:[~2019-02-14 18:56 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-02-14 11:13 Paulo Matos
2019-02-14 18:56 ` Jim Wilson [this message]
2019-02-15  7:33   ` Paulo Matos
2019-02-15 18:15     ` Jim Wilson
2019-02-15 19:27       ` Paulo Matos

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=e64251a9-5f2d-aacc-5666-03c8dba622f7@sifive.com \
    --to=jimw@sifive.com \
    --cc=gcc@gcc.gnu.org \
    --cc=pmatos@linki.tools \
    /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).