public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug tree-optimization/56764] New: vect_prune_runtime_alias_test_list not smart enough
@ 2013-03-28 13:00 jakub at gcc dot gnu.org
  2013-03-28 13:15 ` [Bug tree-optimization/56764] " rguenth at gcc dot gnu.org
                   ` (3 more replies)
  0 siblings, 4 replies; 5+ messages in thread
From: jakub at gcc dot gnu.org @ 2013-03-28 13:00 UTC (permalink / raw)
  To: gcc-bugs


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=56764

             Bug #: 56764
           Summary: vect_prune_runtime_alias_test_list not smart enough
    Classification: Unclassified
           Product: gcc
           Version: 4.8.0
            Status: UNCONFIRMED
          Keywords: missed-optimization
          Severity: normal
          Priority: P3
         Component: tree-optimization
        AssignedTo: unassigned@gcc.gnu.org
        ReportedBy: jakub@gcc.gnu.org


__attribute__((noinline, noclone)) void
foo (float x[3][32], float y1, float y2, float y3, float *z1, float *z2, float
*z3)
{
  int i;
  for (i = 0; i < 32; i++)
    {
      z1[i] = -y1 * x[0][i];
      z2[i] = -y2 * x[1][i];
      z3[i] = -y3 * x[2][i];
    }
}

float x[6][32] __attribute__((aligned (32)));

int
main ()
{
  int i;
  for (i = 0; i < 32; i++)
    {
      x[0][i] = i;
      x[1][i] = 7 * i;
      x[2][i] = -5.5 * i;
    }
  for (i = 0; i < 100000000; i++)
    foo (&x[0], 12.5, 0.5, -1.5, &x[3][0], &x[4][0], &x[5][0]);
  return 0;
}

isn't vectorized on x86_64-linux with -O3 -mavx, because there are too many
versioning checks for alias.  We vectorize it only with
--param vect-max-version-for-alias-checks=12 .  But I don't see why we'd need
to emit that many checks for versioning, instead of the 12 checks for aliasing
we emit we could emit just 6 (keep the 3 overlap checks in between z1, z2 and
z3
and just merge each of the zN vs. &x[0][0], zN vs. &x[1][0] and zN vs. &x[2][0]
tests into one comparing zN[0] though zN[31] range with &x[0][0] through
&x[2][31].  Similarly, if we wanted to do a runtime check for alignment (not
the case on x86_64 apparently), we could test only alignment of &x[0][0],
because
it is provably the same alignment as &x[1][0] and &x[2][0].


^ permalink raw reply	[flat|nested] 5+ messages in thread

* [Bug tree-optimization/56764] vect_prune_runtime_alias_test_list not smart enough
  2013-03-28 13:00 [Bug tree-optimization/56764] New: vect_prune_runtime_alias_test_list not smart enough jakub at gcc dot gnu.org
@ 2013-03-28 13:15 ` rguenth at gcc dot gnu.org
  2013-11-07 18:55 ` congh at google dot com
                   ` (2 subsequent siblings)
  3 siblings, 0 replies; 5+ messages in thread
From: rguenth at gcc dot gnu.org @ 2013-03-28 13:15 UTC (permalink / raw)
  To: gcc-bugs


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=56764

Richard Biener <rguenth at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|UNCONFIRMED                 |NEW
   Last reconfirmed|                            |2013-03-28
             Blocks|                            |53947
     Ever Confirmed|0                           |1

--- Comment #1 from Richard Biener <rguenth at gcc dot gnu.org> 2013-03-28 13:15:28 UTC ---
There is a dup for this bug.  The whole alias test construction machinery
needs to be re-written to support merging tests for adjacent DRs.


^ permalink raw reply	[flat|nested] 5+ messages in thread

* [Bug tree-optimization/56764] vect_prune_runtime_alias_test_list not smart enough
  2013-03-28 13:00 [Bug tree-optimization/56764] New: vect_prune_runtime_alias_test_list not smart enough jakub at gcc dot gnu.org
  2013-03-28 13:15 ` [Bug tree-optimization/56764] " rguenth at gcc dot gnu.org
@ 2013-11-07 18:55 ` congh at google dot com
  2013-11-07 19:29 ` congh at gcc dot gnu.org
  2015-06-11 12:19 ` alalaw01 at gcc dot gnu.org
  3 siblings, 0 replies; 5+ messages in thread
From: congh at google dot com @ 2013-11-07 18:55 UTC (permalink / raw)
  To: gcc-bugs

http://gcc.gnu.org/bugzilla/show_bug.cgi?id=56764

Cong Hou <congh at google dot com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |congh at google dot com

--- Comment #2 from Cong Hou <congh at google dot com> ---
I have made a patch on this issue. However, I don't think the example here is
proper. Say z1 == &(x[0][4]) (assume VF=4). Then after unrolling the loop for 4
times, there is still no data dependence that prevents vectorization.

I think a better example is like the one shown below:



__attribute__((noinline, noclone)) void
foo (float x[3][32], float y1, float y2, float y3, float *z1, float *z2, float
*z3)
{
  int i;
  for (i = 0; i < 16; i++)
    {
      z1[i] = -y1 * x[0][i*2];
      z2[i] = -y2 * x[1][i*2];
      z3[i] = -y3 * x[2][i*2];
    }
}


Here we have to make sure z1/z2/z3 does not alias with x across the whole range
being traversed. Then we could merge the alias checks between z1 and
&x[0][0:32]/&x[1][0:32]/&x[2][0:32] into one.


^ permalink raw reply	[flat|nested] 5+ messages in thread

* [Bug tree-optimization/56764] vect_prune_runtime_alias_test_list not smart enough
  2013-03-28 13:00 [Bug tree-optimization/56764] New: vect_prune_runtime_alias_test_list not smart enough jakub at gcc dot gnu.org
  2013-03-28 13:15 ` [Bug tree-optimization/56764] " rguenth at gcc dot gnu.org
  2013-11-07 18:55 ` congh at google dot com
@ 2013-11-07 19:29 ` congh at gcc dot gnu.org
  2015-06-11 12:19 ` alalaw01 at gcc dot gnu.org
  3 siblings, 0 replies; 5+ messages in thread
From: congh at gcc dot gnu.org @ 2013-11-07 19:29 UTC (permalink / raw)
  To: gcc-bugs

http://gcc.gnu.org/bugzilla/show_bug.cgi?id=56764

--- Comment #3 from congh at gcc dot gnu.org ---
Author: congh
Date: Thu Nov  7 19:29:45 2013
New Revision: 204538

URL: http://gcc.gnu.org/viewcvs?rev=204538&root=gcc&view=rev
Log:
2013-11-07  Cong Hou  <congh@google.com>

    PR tree-optimization/56764
    * tree-vect-loop-manip.c (vect_create_cond_for_alias_checks):
      Combine alias checks if it is possible to amortize the runtime
      overhead.  Return the number of alias checks after merging.
      * tree-vect-data-refs.c (vect_prune_runtime_alias_test_list):
        Use the function vect_create_cond_for_alias_checks () to check
        the number of alias checks.

2013-11-07  Cong Hou  <congh@google.com>

        * gcc.dg/vect/vect-alias-check.c: New.


Added:
    trunk/gcc/testsuite/gcc.dg/vect/vect-alias-check.c
Modified:
    trunk/gcc/ChangeLog
    trunk/gcc/testsuite/ChangeLog
    trunk/gcc/tree-vect-data-refs.c
    trunk/gcc/tree-vect-loop-manip.c
    trunk/gcc/tree-vectorizer.h


^ permalink raw reply	[flat|nested] 5+ messages in thread

* [Bug tree-optimization/56764] vect_prune_runtime_alias_test_list not smart enough
  2013-03-28 13:00 [Bug tree-optimization/56764] New: vect_prune_runtime_alias_test_list not smart enough jakub at gcc dot gnu.org
                   ` (2 preceding siblings ...)
  2013-11-07 19:29 ` congh at gcc dot gnu.org
@ 2015-06-11 12:19 ` alalaw01 at gcc dot gnu.org
  3 siblings, 0 replies; 5+ messages in thread
From: alalaw01 at gcc dot gnu.org @ 2015-06-11 12:19 UTC (permalink / raw)
  To: gcc-bugs

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=56764

alalaw01 at gcc dot gnu.org changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|NEW                         |RESOLVED
                 CC|                            |alalaw01 at gcc dot gnu.org
         Resolution|---                         |FIXED

--- Comment #6 from alalaw01 at gcc dot gnu.org ---
This vectorizes now on x86_64 and aarch64 at -O3.


^ permalink raw reply	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2015-06-11 12:19 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2013-03-28 13:00 [Bug tree-optimization/56764] New: vect_prune_runtime_alias_test_list not smart enough jakub at gcc dot gnu.org
2013-03-28 13:15 ` [Bug tree-optimization/56764] " rguenth at gcc dot gnu.org
2013-11-07 18:55 ` congh at google dot com
2013-11-07 19:29 ` congh at gcc dot gnu.org
2015-06-11 12:19 ` alalaw01 at gcc dot gnu.org

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).