public inbox for gcc-patches@gcc.gnu.org
 help / color / mirror / Atom feed
From: Richard Biener <richard.guenther@gmail.com>
To: gcc-patches@gcc.gnu.org,"Bin.Cheng"
	<amker.cheng@gmail.com>,Robin Dapp <rdapp@linux.vnet.ibm.com>
Cc: GCC Patches <gcc-patches@gcc.gnu.org>
Subject: Re: [RFC] S/390: Alignment peeling prolog generation
Date: Tue, 11 Apr 2017 16:25:00 -0000	[thread overview]
Message-ID: <2804E9EF-67D1-4EFD-AF29-65C634EBE24F@gmail.com> (raw)
In-Reply-To: <CAHFci282BedKpc99pxk1+PLHc7OxkE0bFZHRn1rsE9X+-ihuDQ@mail.gmail.com>

On April 11, 2017 4:57:29 PM GMT+02:00, "Bin.Cheng" <amker.cheng@gmail.com> wrote:
>On Tue, Apr 11, 2017 at 3:38 PM, Robin Dapp <rdapp@linux.vnet.ibm.com>
>wrote:
>> Hi,
>>
>> when looking at various vectorization examples on s390x I noticed
>that
>> we still peel vf/2 iterations for alignment even though vectorization
>> costs of unaligned loads and stores are the same as normal
>loads/stores.
>>
>> A simple example is
>>
>> void foo(int *restrict a, int *restrict b, unsigned int n)
>> {
>>   for (unsigned int i = 0; i < n; i++)
>>     {
>>       b[i] = a[i] * 2 + 1;
>>     }
>> }
>>
>> which gets peeled unless __builtin_assume_aligned (a, 8) is used.
>>
>> In tree-vect-data-refs.c there are several checks that involve costs 
>in
>> the peeling decision none of which seems to suffice in this case. For
>a
>> loop with only read DRs there is a check that has been triggering
>(i.e.
>> disable peeling) since we implemented the vectorization costs.
>>
>> Here, we have DR_MISALIGNMENT (dr) == -1 for all DRs but the costs
>> should still dictate to never peel. I attached a tentative patch for
>> discussion which fixes the problem by checking the costs for npeel =
>0
>> and npeel = vf/2 after ensuring we support all misalignments. Is
>there a
>> better way and place to do it? Are we missing something somewhere
>else
>> that would preclude the peeling from happening?
>>
>> This is not indended for stage 4 obviously :)
>Hi Robin,
>Seems Richi added code like below comparing costs between aligned and
>unsigned loads, and only peeling if it's beneficial:
>
>/* In case there are only loads with different unknown misalignments,
>use
>     peeling only if it may help to align other accesses in the loop or
>     if it may help improving load bandwith when we'd end up using
>     unaligned loads.  */
>     tree dr0_vt = STMT_VINFO_VECTYPE (vinfo_for_stmt (DR_STMT (dr0)));
>      if (!first_store
>      && !STMT_VINFO_SAME_ALIGN_REFS (
>          vinfo_for_stmt (DR_STMT (dr0))).length ()
>      && (vect_supportable_dr_alignment (dr0, false)
>          != dr_unaligned_supported
>          || (builtin_vectorization_cost (vector_load, dr0_vt, 0)
>          == builtin_vectorization_cost (unaligned_load, dr0_vt, -1))))
>        do_peeling = false;
>
>I think similar codes can be added for store cases too.

Note I was very conservative here to allow store bandwidth starved CPUs to benefit from aligning a store.

I think it would be reasonable to apply the same heuristic to the store case that we only peel for same cost if peeling would at least align two refs.

Richard.

>Thanks,
>bin
>>
>> Regards
>>  Robin

  parent reply	other threads:[~2017-04-11 16:25 UTC|newest]

Thread overview: 51+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2017-04-11 14:38 Robin Dapp
2017-04-11 14:57 ` Bin.Cheng
2017-04-11 15:03   ` Robin Dapp
2017-04-11 15:07     ` Bin.Cheng
2017-04-11 16:25   ` Richard Biener [this message]
2017-04-12  7:51     ` Robin Dapp
2017-04-12  7:58       ` Richard Biener
2017-05-04  9:04         ` [PATCH 1/3] Vect peeling cost model Robin Dapp
2017-05-05 10:32           ` Richard Biener
2017-05-04  9:04         ` [RFC] S/390: Alignment peeling prolog generation Robin Dapp
2017-05-05 11:04           ` Richard Biener
2017-05-08 16:12             ` Robin Dapp
2017-05-09 10:38               ` Richard Biener
2017-05-11 11:17                 ` [PATCH 1/5] Vect peeling cost model Robin Dapp
2017-05-11 11:17                 ` [RFC] S/390: Alignment peeling prolog generation Robin Dapp
2017-05-11 12:15                   ` Richard Biener
2017-05-11 12:16                     ` Richard Biener
2017-05-11 12:48                       ` Richard Biener
2017-05-11 11:18                 ` [PATCH 2/5] Vect peeling cost model Robin Dapp
2017-05-11 11:19                 ` [PATCH 3/5] " Robin Dapp
2017-05-11 11:20                 ` [PATCH 4/5] " Robin Dapp
2017-05-11 15:30                   ` [PATCH 4/5 v2] " Robin Dapp
2017-05-12  9:36                     ` Richard Biener
2017-05-23 15:58                       ` [PATCH 1/5 v3] " Robin Dapp
2017-05-23 15:58                       ` [PATCH 0/5 " Robin Dapp
2017-05-24  7:51                         ` Richard Biener
2017-05-24 11:57                           ` Robin Dapp
2017-05-24 13:56                             ` Richard Biener
2017-06-03 17:12                         ` Andreas Schwab
2017-06-06  7:13                           ` Robin Dapp
2017-06-06 17:26                             ` Andreas Schwab
2017-06-07 10:50                               ` Robin Dapp
2017-06-07 11:43                                 ` Andreas Schwab
2017-05-23 15:58                       ` [PATCH 2/5 " Robin Dapp
2017-05-23 19:25                         ` Richard Sandiford
2017-05-24  7:37                           ` Robin Dapp
2017-05-24  7:53                             ` Richard Sandiford
2017-05-23 15:59                       ` [PATCH 4/5 " Robin Dapp
2017-05-31 13:56                         ` Christophe Lyon
2017-05-31 14:37                           ` Robin Dapp
2017-05-31 14:49                             ` Christophe Lyon
2017-05-23 15:59                       ` [PATCH 5/5 " Robin Dapp
2017-05-23 16:02                       ` [PATCH 3/5 " Robin Dapp
2017-05-11 11:59                 ` [PATCH 5/5] " Robin Dapp
2017-05-08 16:13             ` [PATCH 3/4] " Robin Dapp
2017-05-09 10:41               ` Richard Biener
2017-05-08 16:27             ` [PATCH 4/4] " Robin Dapp
2017-05-09 10:55               ` Richard Biener
2017-05-04  9:07         ` [PATCH 2/3] " Robin Dapp
2017-05-05 10:37           ` Richard Biener
2017-05-04  9:14         ` [PATCH 3/3] " Robin Dapp

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=2804E9EF-67D1-4EFD-AF29-65C634EBE24F@gmail.com \
    --to=richard.guenther@gmail.com \
    --cc=amker.cheng@gmail.com \
    --cc=gcc-patches@gcc.gnu.org \
    --cc=rdapp@linux.vnet.ibm.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).