public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug tree-optimization/66718] New: Non-invariant ADDR_EXPR not vectorized
@ 2015-07-01  9:41 jakub at gcc dot gnu.org
  2015-07-01  9:46 ` [Bug tree-optimization/66718] " rguenth at gcc dot gnu.org
                   ` (6 more replies)
  0 siblings, 7 replies; 8+ messages in thread
From: jakub at gcc dot gnu.org @ 2015-07-01  9:41 UTC (permalink / raw)
  To: gcc-bugs

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

            Bug ID: 66718
           Summary: Non-invariant ADDR_EXPR not vectorized
           Product: gcc
           Version: 6.0
            Status: UNCONFIRMED
          Keywords: missed-optimization
          Severity: normal
          Priority: P3
         Component: tree-optimization
          Assignee: unassigned at gcc dot gnu.org
          Reporter: jakub at gcc dot gnu.org
                CC: mpolacek at gcc dot gnu.org, rguenth at gcc dot gnu.org
  Target Milestone: ---

E.g. on:
int *a[1024], b[1024];
struct S { int u, v, w, x; };
struct S c[1024];

void
f0 (void)
{
  for (int i = 0; i < 1024; i++)
    a[i] = &b[0];
}

void
f1 (void)
{
  for (int i = 0; i < 1024; i++)
    {
      int *p = &b[0];
      a[i] = p + i;
    }
}

void
f2 (int *p)
{
  for (int i = 0; i < 1024; i++)
    a[i] = &p[i];
}

void
f3 (void)
{
  for (int i = 0; i < 1024; i++)
    a[i] = &b[i];
}

void
f4 (void)
{
  int *p = &c[0].v;
  for (int i = 0; i < 1024; i++)
    a[i] = &p[4 * i];
}

void
f5 (void)
{
  for (int i = 0; i < 1024; i++)
    a[i] = &c[i].v;
}

with -O3 -mavx2 we vectorize only the loops where the address computation has
been lowered (f1, f2, f4) or is address of invariant (f0), but the vectorizer
is not able to vectorize ADDR_EXPR of non-invariant.

Richard thinks this would be best solved by lowering such ADDR_EXPR
assignments,
somewhere in between the last objsz pass and pre, maybe even before reassoc so
that it can optimize even that.


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

* [Bug tree-optimization/66718] Non-invariant ADDR_EXPR not vectorized
  2015-07-01  9:41 [Bug tree-optimization/66718] New: Non-invariant ADDR_EXPR not vectorized jakub at gcc dot gnu.org
@ 2015-07-01  9:46 ` rguenth at gcc dot gnu.org
  2015-07-01 15:15 ` mpolacek at gcc dot gnu.org
                   ` (5 subsequent siblings)
  6 siblings, 0 replies; 8+ messages in thread
From: rguenth at gcc dot gnu.org @ 2015-07-01  9:46 UTC (permalink / raw)
  To: gcc-bugs

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

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

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|UNCONFIRMED                 |NEW
   Last reconfirmed|                            |2015-07-01
     Ever confirmed|0                           |1

--- Comment #1 from Richard Biener <rguenth at gcc dot gnu.org> ---
forwprop is the only one who does sth "useful" with the non-lowered form
(propagating the addresses into dereferences).  Eventually trying that
very specific transform during the lowering gives more freedom in pass
placement.

Indeed we'd like reassoc to run on the lowering result to expose CSE
opportunities.

I think lowering these makes sense in general and it's a much easier way
(implementation-wise) to get things vectorized as well.

Just do

  get_inner_reference (...)
  force_gimple_operand (...)


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

* [Bug tree-optimization/66718] Non-invariant ADDR_EXPR not vectorized
  2015-07-01  9:41 [Bug tree-optimization/66718] New: Non-invariant ADDR_EXPR not vectorized jakub at gcc dot gnu.org
  2015-07-01  9:46 ` [Bug tree-optimization/66718] " rguenth at gcc dot gnu.org
@ 2015-07-01 15:15 ` mpolacek at gcc dot gnu.org
  2015-07-05 12:12 ` jakub at gcc dot gnu.org
                   ` (4 subsequent siblings)
  6 siblings, 0 replies; 8+ messages in thread
From: mpolacek at gcc dot gnu.org @ 2015-07-01 15:15 UTC (permalink / raw)
  To: gcc-bugs

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

Marek Polacek <mpolacek at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|NEW                         |ASSIGNED
           Assignee|unassigned at gcc dot gnu.org      |mpolacek at gcc dot gnu.org
   Target Milestone|---                         |6.0

--- Comment #2 from Marek Polacek <mpolacek at gcc dot gnu.org> ---
I've started looking into this.


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

* [Bug tree-optimization/66718] Non-invariant ADDR_EXPR not vectorized
  2015-07-01  9:41 [Bug tree-optimization/66718] New: Non-invariant ADDR_EXPR not vectorized jakub at gcc dot gnu.org
  2015-07-01  9:46 ` [Bug tree-optimization/66718] " rguenth at gcc dot gnu.org
  2015-07-01 15:15 ` mpolacek at gcc dot gnu.org
@ 2015-07-05 12:12 ` jakub at gcc dot gnu.org
  2015-07-05 12:15 ` jakub at gcc dot gnu.org
                   ` (3 subsequent siblings)
  6 siblings, 0 replies; 8+ messages in thread
From: jakub at gcc dot gnu.org @ 2015-07-05 12:12 UTC (permalink / raw)
  To: gcc-bugs

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

--- Comment #3 from Jakub Jelinek <jakub at gcc dot gnu.org> ---
Author: jakub
Date: Sun Jul  5 12:11:57 2015
New Revision: 225433

URL: https://gcc.gnu.org/viewcvs?rev=225433&root=gcc&view=rev
Log:
        PR tree-optimization/66718
        * tree-vect-stmts.c (vectorizable_assignment, vectorizable_store,
        vectorizable_load, vectorizable_condition): Move vectype,
        nunits, ncopies computation after checking what kind of statement
        stmt is.

Modified:
    trunk/gcc/ChangeLog
    trunk/gcc/tree-vect-stmts.c


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

* [Bug tree-optimization/66718] Non-invariant ADDR_EXPR not vectorized
  2015-07-01  9:41 [Bug tree-optimization/66718] New: Non-invariant ADDR_EXPR not vectorized jakub at gcc dot gnu.org
                   ` (2 preceding siblings ...)
  2015-07-05 12:12 ` jakub at gcc dot gnu.org
@ 2015-07-05 12:15 ` jakub at gcc dot gnu.org
  2015-07-09  9:02 ` mpolacek at gcc dot gnu.org
                   ` (2 subsequent siblings)
  6 siblings, 0 replies; 8+ messages in thread
From: jakub at gcc dot gnu.org @ 2015-07-05 12:15 UTC (permalink / raw)
  To: gcc-bugs

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

--- Comment #4 from Jakub Jelinek <jakub at gcc dot gnu.org> ---
Author: jakub
Date: Sun Jul  5 12:14:41 2015
New Revision: 225434

URL: https://gcc.gnu.org/viewcvs?rev=225434&root=gcc&view=rev
Log:
        PR tree-optimization/66718
        * tree-vect-stmts.c (vectorizable_call): Replace uses of
        GOMP_SIMD_LANE outside of loop with vf - 1 rather than 0.

Modified:
    trunk/gcc/ChangeLog
    trunk/gcc/tree-vect-stmts.c


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

* [Bug tree-optimization/66718] Non-invariant ADDR_EXPR not vectorized
  2015-07-01  9:41 [Bug tree-optimization/66718] New: Non-invariant ADDR_EXPR not vectorized jakub at gcc dot gnu.org
                   ` (3 preceding siblings ...)
  2015-07-05 12:15 ` jakub at gcc dot gnu.org
@ 2015-07-09  9:02 ` mpolacek at gcc dot gnu.org
  2015-07-09  9:06 ` mpolacek at gcc dot gnu.org
  2015-07-09 21:12 ` jakub at gcc dot gnu.org
  6 siblings, 0 replies; 8+ messages in thread
From: mpolacek at gcc dot gnu.org @ 2015-07-09  9:02 UTC (permalink / raw)
  To: gcc-bugs

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

--- Comment #5 from Marek Polacek <mpolacek at gcc dot gnu.org> ---
Author: mpolacek
Date: Thu Jul  9 09:01:51 2015
New Revision: 225604

URL: https://gcc.gnu.org/viewcvs?rev=225604&root=gcc&view=rev
Log:
        PR tree-optimization/66718
        * Makefile.in (OBJS): Add gimple-laddress.o. 
        * passes.def: Schedule pass_laddress.
        * timevar.def (DEFTIMEVAR): Add TV_GIMPLE_LADDRESS.
        * tree-pass.h (make_pass_laddress): Declare.
        * gimple-laddress.c: New file.

        * gcc.dg/vect/vect-126.c: New test.

Added:
    trunk/gcc/gimple-laddress.c
    trunk/gcc/testsuite/gcc.dg/vect/vect-126.c
Modified:
    trunk/gcc/ChangeLog
    trunk/gcc/Makefile.in
    trunk/gcc/passes.def
    trunk/gcc/testsuite/ChangeLog
    trunk/gcc/timevar.def
    trunk/gcc/tree-pass.h


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

* [Bug tree-optimization/66718] Non-invariant ADDR_EXPR not vectorized
  2015-07-01  9:41 [Bug tree-optimization/66718] New: Non-invariant ADDR_EXPR not vectorized jakub at gcc dot gnu.org
                   ` (4 preceding siblings ...)
  2015-07-09  9:02 ` mpolacek at gcc dot gnu.org
@ 2015-07-09  9:06 ` mpolacek at gcc dot gnu.org
  2015-07-09 21:12 ` jakub at gcc dot gnu.org
  6 siblings, 0 replies; 8+ messages in thread
From: mpolacek at gcc dot gnu.org @ 2015-07-09  9:06 UTC (permalink / raw)
  To: gcc-bugs

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

Marek Polacek <mpolacek at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|ASSIGNED                    |RESOLVED
         Resolution|---                         |FIXED

--- Comment #6 from Marek Polacek <mpolacek at gcc dot gnu.org> ---
The test in the description is fully vectorized now, so fixed.


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

* [Bug tree-optimization/66718] Non-invariant ADDR_EXPR not vectorized
  2015-07-01  9:41 [Bug tree-optimization/66718] New: Non-invariant ADDR_EXPR not vectorized jakub at gcc dot gnu.org
                   ` (5 preceding siblings ...)
  2015-07-09  9:06 ` mpolacek at gcc dot gnu.org
@ 2015-07-09 21:12 ` jakub at gcc dot gnu.org
  6 siblings, 0 replies; 8+ messages in thread
From: jakub at gcc dot gnu.org @ 2015-07-09 21:12 UTC (permalink / raw)
  To: gcc-bugs

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

--- Comment #7 from Jakub Jelinek <jakub at gcc dot gnu.org> ---
Author: jakub
Date: Thu Jul  9 21:11:28 2015
New Revision: 225637

URL: https://gcc.gnu.org/viewcvs?rev=225637&root=gcc&view=rev
Log:
        PR tree-optimization/66718
        * tree-vect-stmts.c (struct simd_call_arg_info): Add simd_lane_linear
        field.
        (vect_simd_lane_linear): New function.
        (vectorizable_simd_clone_call): Support using linear arguments for
        addresses of arrays elements indexed by GOMP_SIMD_LANE result.

Modified:
    trunk/gcc/ChangeLog
    trunk/gcc/tree-vect-stmts.c


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

end of thread, other threads:[~2015-07-09 21:12 UTC | newest]

Thread overview: 8+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2015-07-01  9:41 [Bug tree-optimization/66718] New: Non-invariant ADDR_EXPR not vectorized jakub at gcc dot gnu.org
2015-07-01  9:46 ` [Bug tree-optimization/66718] " rguenth at gcc dot gnu.org
2015-07-01 15:15 ` mpolacek at gcc dot gnu.org
2015-07-05 12:12 ` jakub at gcc dot gnu.org
2015-07-05 12:15 ` jakub at gcc dot gnu.org
2015-07-09  9:02 ` mpolacek at gcc dot gnu.org
2015-07-09  9:06 ` mpolacek at gcc dot gnu.org
2015-07-09 21:12 ` jakub 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).