public inbox for gcc-patches@gcc.gnu.org
 help / color / mirror / Atom feed
From: Qing Zhao <qing.zhao@oracle.com>
To: David Miller <davem@davemloft.net>
Cc: gcc-patches@gcc.gnu.org
Subject: Re: [PATCH 1/1] sparc: support for -mmisalign in the SPARC M8
Date: Thu, 03 Aug 2017 18:49:00 -0000	[thread overview]
Message-ID: <4EF10823-F692-407B-A085-292DCC6DF7E6@oracle.com> (raw)
In-Reply-To: <20170803.094054.1765286132092334063.davem@davemloft.net>


> On Aug 3, 2017, at 11:40 AM, David Miller <davem@davemloft.net> wrote:
> 
> From: Qing Zhao <qing.zhao@oracle.com>
> Date: Thu, 3 Aug 2017 10:37:15 -0500
> 
>> all the special handling on STRICT_ALIGNMENT or
>> SLOW_UNALIGNMENT_ACCESS in these codes have the following common
>> logic:
>> 
>> if the memory access is known to be not-aligned well during
>> compilation time, if the targeted platform does NOT support faster
>> unaligned memory access, the compiler will try to make the memory
>> access aligned well. Otherwise, if the targeted platform supports
>> faster unaligned memory access, it will leave the compiler-time
>> known not-aligned memory access as it, later the hardware support
>> will kicked in for these unaligned memory access.
>> 
>> this behavior is consistent with the high level definition of STRICT_ALIGNMENT. 
> 
> That's exactly the problem.
> 
> What you want with this M8 feature is simply to let the compiler know
> that if it is completely impossible to make some memory object
> aligned, then the cpu can handle this with special instructions.

> 
> You still want the compiler to make the effort to align data when it
> can because the accesses will be faster than if it used the unaligned
> loads and stores.

I don’t think the above is true.

first, the compiler-time known misaligned memory access can always be emulated by aligned memory access ( by byte-size load/stores).  then there will be no compiler-time known 
misaligned memory access left for the special misaligned ld/st insns. 

second, there are always overhead cost for the compiler-time effort to make the compiler-time known unaligned memory access as aligned memory access. (adding additional
padding, or split the unaligned multi-bytes to single-byte load/store), all such overhead might be even bigger than the overhead of the special misaligned load/store itself.

to decide which is better (to use software emulation or use hardware misaligned load/store insns), experiments might be needed to justify the performance impact.

This set of change is to provide a way to use misaligned load/store insns to implement the compiler-time known unaligned memory access,  -mno-misalign can be used
to disable such behavior very easily if our performance data shows that misaligned load/store insns are slower than the current software emulation. 

Qing


> 
> This is incredibly important for on-stack objects.

  reply	other threads:[~2017-08-03 18:49 UTC|newest]

Thread overview: 9+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
     [not found] <SPARC_MISALIGN_PATCH>
2017-08-02 15:28 ` qinzhao
2017-08-02 16:43   ` David Miller
2017-08-02 20:16     ` Qing Zhao
     [not found]     ` <A872C63E-CC39-4E10-84D7-D1CAB7E72716@oracle.com>
2017-08-02 23:17       ` David Miller
2017-08-03 13:44         ` Qing Zhao
2017-08-03 15:37           ` Qing Zhao
2017-08-03 16:41             ` David Miller
2017-08-03 18:49               ` Qing Zhao [this message]
2017-09-06 19:41                 ` Qing Zhao

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=4EF10823-F692-407B-A085-292DCC6DF7E6@oracle.com \
    --to=qing.zhao@oracle.com \
    --cc=davem@davemloft.net \
    --cc=gcc-patches@gcc.gnu.org \
    /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).