public inbox for gcc-patches@gcc.gnu.org
 help / color / mirror / Atom feed
From: Uros Bizjak <ubizjak@gmail.com>
To: Eric Botcazou <ebotcazou@adacore.com>
Cc: Kirill Yukhin <kirill.yukhin@gmail.com>,
		"gcc-patches@gcc.gnu.org" <gcc-patches@gcc.gnu.org>,
	Richard Henderson <rth@redhat.com>,
		Jakub Jelinek <jakub@redhat.com>
Subject: Re: [PATCH i386 5/8] [AVX-512] Extend vectorizer hooks.
Date: Fri, 03 Jan 2014 11:03:00 -0000	[thread overview]
Message-ID: <CAFULd4bqaCZcJZmqZ9Cj=5vUJzofKJWg2hDxCm=-2g6yte66zQ@mail.gmail.com> (raw)
In-Reply-To: <201401022318.15106.ebotcazou@adacore.com>

On Thu, Jan 2, 2014 at 11:18 PM, Eric Botcazou <ebotcazou@adacore.com> wrote:
>> Note that it has unexpected side-effects: previously, in 32-bit mode,
>> 256-bit aggregate objects would have been given 256-bit alignment; now,
>> they will fall back to default alignment, for example 32-bit only.
>
> In case this wasn't clear enough, just compile in 32-bit mode:
>
> int a[8] = { 1, 2, 3, 4, 5, 6, 7, 8};

It looks to me that we don't need to adjust anything with max_align.
Using following patch:

--cut here--
Index: i386.c
===================================================================
--- i386.c      (revision 206311)
+++ i386.c      (working copy)
@@ -26465,6 +26465,7 @@
 int
 ix86_data_alignment (tree type, int align, bool opt)
 {
+#if 0
   int max_align = optimize_size ? BITS_PER_WORD
                                : MIN (512, MAX_OFILE_ALIGNMENT);

@@ -26476,6 +26477,7 @@
          || TREE_INT_CST_HIGH (TYPE_SIZE (type)))
       && align < max_align)
     align = max_align;
+#endif

   /* x86-64 ABI requires arrays greater than 16 bytes to be aligned
      to 16byte boundary.  */
--cut here--

and following testcase:

-- cut here--
float a[8] = { 1, 2, 3, 4, 5, 6, 7, 8};

extern float z[8];

void t (void)
{
  int i;

  for (i = 0; i < 8; i++)
    z[i] = z[i] + a[i];
}
--cut here--

When compiled with -m32 -mavx, we get:

        .align 32
        .type   a, @object
        .size   a, 32
a:

so, the alignment was already raised elsewhere. We get .align 16 for
-msse -m32 when vectorizing.

without -msse (and consequently without vectorizing), we get for -m32:

        .align 4
        .type   a, @object
        .size   a, 32
a:

which corresponds to 32bit ABI rules (we still get .align16 for 64bit ABI).

What bothers me in this testcase is (unrelated) alignment of z[8]
array. Even for 64bit targets, we get:

#(insn:TI 6 5 8 2 (set (reg:V4SF 21 xmm0 [orig:90 vect__4.5 ] [90])
#        (unspec:V4SF [
#                (mem/c:V4SF (reg/f:DI 0 ax [89]) [2 MEM[(float
*)&z]+0 S16 A32])
#            ] UNSPEC_LOADU)) al.c:10 1195 {*sse_loadups}
#     (nil))
        movups  (%rax), %xmm0   # 6     *sse_loadups    [length = 3]

ABI guarantees 16 byte alignment of z[8], but we fail to communicate
this to the compiler.

Uros.

  reply	other threads:[~2014-01-03 11:03 UTC|newest]

Thread overview: 43+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2013-11-12 13:56 Kirill Yukhin
2013-11-15 18:21 ` Kirill Yukhin
2013-11-19 10:28   ` Kirill Yukhin
2013-12-02 13:16     ` Kirill Yukhin
2013-12-18 13:08       ` Kirill Yukhin
2013-12-22 10:47         ` Uros Bizjak
2013-12-22 12:52           ` Jakub Jelinek
2013-12-30 11:00           ` Kirill Yukhin
2014-01-01 23:08             ` Eric Botcazou
2014-01-02 10:53               ` Kirill Yukhin
2014-01-02 15:12                 ` Eric Botcazou
2014-01-02 19:50                   ` Jan Hubicka
2014-01-02 21:56                     ` Eric Botcazou
2014-01-02 22:16                       ` Jan Hubicka
2014-01-02 22:18               ` Eric Botcazou
2014-01-03 11:03                 ` Uros Bizjak [this message]
2014-01-03 11:20                   ` Eric Botcazou
2014-01-03 11:25                     ` Uros Bizjak
2014-01-03 12:00                       ` Jakub Jelinek
2014-01-03 12:27                         ` Uros Bizjak
2014-01-03 13:35                           ` Uros Bizjak
2014-01-03 13:43                             ` Jakub Jelinek
2014-01-03 14:02                               ` Uros Bizjak
2014-01-03 14:13                                 ` Jakub Jelinek
2014-01-03 14:35                                   ` Uros Bizjak
2014-01-03 14:42                                     ` Jakub Jelinek
2014-01-03 16:04                                 ` Uros Bizjak
2014-01-14 17:09                                   ` Jakub Jelinek
2014-01-14 18:37                                     ` Uros Bizjak
2014-01-14 19:00                                       ` H.J. Lu
2014-01-14 19:12                                       ` Jakub Jelinek
2014-01-17 14:15                                         ` Jakub Jelinek
2014-01-17 14:25                                           ` Uros Bizjak
2014-05-19  4:48                             ` Jan Hubicka
2014-05-19 16:14                               ` Uros Bizjak
2014-05-19 16:42                                 ` H.J. Lu
2014-05-19 16:45                                   ` Uros Bizjak
2014-05-19 16:58                                     ` H.J. Lu
2014-05-20 12:00                                       ` Kirill Yukhin
2014-05-20 15:24                                         ` H.J. Lu
2014-05-22  9:02                                           ` Kirill Yukhin
2014-05-22 17:38                                             ` H.J. Lu
2014-05-30 17:23                                               ` H.J. Lu

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='CAFULd4bqaCZcJZmqZ9Cj=5vUJzofKJWg2hDxCm=-2g6yte66zQ@mail.gmail.com' \
    --to=ubizjak@gmail.com \
    --cc=ebotcazou@adacore.com \
    --cc=gcc-patches@gcc.gnu.org \
    --cc=jakub@redhat.com \
    --cc=kirill.yukhin@gmail.com \
    --cc=rth@redhat.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).