From: Martin Sebor <msebor@gmail.com>
To: gcc mailing list <gcc@gcc.gnu.org>
Subject: vector alignment
Date: Tue, 02 Apr 2019 16:20:00 -0000 [thread overview]
Message-ID: <e6fd3216-8581-55a6-24ee-c41662c946da@gmail.com> (raw)
GCC tries to align a vector on its natural boundary, i.e., that
given by its size, up to MAX_OBJECT_ALIGNMENT. Vectors that are
bigger than that are either silently [mis]aligned on that same
maximum boundary (PR 89798), silently truncated (and misaligned),
or cause an ICE (PR 89797). Compiling the following:
__attribute__ ((vector_size (N))) char v;
_Static_assert (sizeof (v) == N, "size");
_Static_assert (__alignof__ (v) == N, "alignment");
with N set to 1LLU << I shows these failures:
I < 29 succeeds
I < 31 fails alignment
I < 32 ICE
I >= 32 fails alignment and size
Attribute aligned doesn't seem to have any effect on types or
variables declared with attribute vector_size. The alignment
set by the latter prevails.
This happens no matter what scope the vector is defined in (i.e.,
file or local).
I have some questions:
1) Is there some reason to align vectors on the same boundary
as their size no matter how big it is? I can't find such
a requirement in the ABIs I looked at. Or would it be more
appropriate to align the big ones on the preferred boundary
for the target? For instance, does it make more sense to
align a 64KB vector on a 64KB boundary than on, say,
a 64-byte boundary (or some other boundary less than 64K?)
2) If not, is it then appropriate to underalign very large
vectors on a boundary less than their size?
3) Should the aligned attribute not override the default vector
alignment?
I would like to think the answer to (1) is that vectors should
be aligned on the preferred boundary for the target/ABI. If
that's feasible, it should also obviate question (2).
I believe the answer to (3) is yes. If not, GCC should issue
a warning that it doesn't honor the aligned attribute.
Thanks
Martin
next reply other threads:[~2019-04-02 16:20 UTC|newest]
Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top
2019-04-02 16:20 Martin Sebor [this message]
2019-04-03 11:14 ` Richard Biener
2019-04-03 17:59 ` Martin Sebor
2019-04-04 5:40 ` Richard Biener
2019-04-04 16:14 ` Martin Sebor
2019-04-17 15:12 ` Joseph Myers
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=e6fd3216-8581-55a6-24ee-c41662c946da@gmail.com \
--to=msebor@gmail.com \
--cc=gcc@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).