public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug tree-optimization/101178] New: SLP permute propagation doesn't handle VEC_PERM
@ 2021-06-23 10:12 rguenth at gcc dot gnu.org
  2021-06-23 10:12 ` [Bug tree-optimization/101178] " rguenth at gcc dot gnu.org
                   ` (3 more replies)
  0 siblings, 4 replies; 5+ messages in thread
From: rguenth at gcc dot gnu.org @ 2021-06-23 10:12 UTC (permalink / raw)
  To: gcc-bugs

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

            Bug ID: 101178
           Summary: SLP permute propagation doesn't handle VEC_PERM
           Product: gcc
           Version: 12.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: tree-optimization
          Assignee: unassigned at gcc dot gnu.org
          Reporter: rguenth at gcc dot gnu.org
  Target Milestone: ---

The current permute propagation code simply treats VEC_PERM nodes as
materialization points (they can consume incoming permutes) but it does
neither handle them as sources for permutes nor does it consider propagating
a common source permute through itself.  The latter can be seen for

double x[2], y[2], z[2], w[2];

void foo ()
{
  double tem0 = x[1] + y[1];
  double tem1 = x[0] - y[0];
  double tem2 = z[1] * tem0;
  double tem3 = z[0] * tem1;
  z[0] = tem2 - w[0];
  z[1] = tem3 + w[1];
}

where we do not end up materializing the x[], y[] and w[] permute at
the last +- node but instead materialize at the first +- node and thus
end up with incoming permute differences at the second +- one:

  <bb 2> [local count: 1073741824]:
  _21 = &x[1] + 18446744073709551608;
  vect__3.9_22 = MEM <vector(2) double> [(double *)_21];
  _1 = x[1];
  _23 = &y[1] + 18446744073709551608;
  vect__4.12_24 = MEM <vector(2) double> [(double *)_23];
  vect_tem1_13.14_26 = vect__3.9_22 - vect__4.12_24;
  vect_tem0_12.13_25 = vect__3.9_22 + vect__4.12_24;
  _27 = VEC_PERM_EXPR <vect_tem0_12.13_25, vect_tem1_13.14_26, { 1, 2 }>;
  _2 = y[1];
  tem0_12 = _1 + _2;
  _3 = x[0];
  _4 = y[0];
  tem1_13 = _3 - _4;
  _18 = &z[1] + 18446744073709551608;
  vect__5.5_19 = MEM <vector(2) double> [(double *)_18];
  vect__6.6_20 = VEC_PERM_EXPR <vect__5.5_19, vect__5.5_19, { 1, 0 }>;
  vect_tem2_14.15_28 = vect__6.6_20 * _27;
  _5 = z[1];
  tem2_14 = _5 * tem0_12;
  _6 = z[0];
  tem3_15 = _6 * tem1_13;
  vect__7.18_29 = MEM <vector(2) double> [(double *)&w];
  vect__10.20_31 = vect_tem2_14.15_28 + vect__7.18_29;
  vect__8.19_30 = vect_tem2_14.15_28 - vect__7.18_29;
  _32 = VEC_PERM_EXPR <vect__8.19_30, vect__10.20_31, { 0, 3 }>;
  _7 = w[0];
  _8 = tem2_14 - _7;
  _9 = w[1];
  _10 = _9 + tem3_15;
  MEM <vector(2) double> [(double *)&z] = _32;

The permute vect__6.6_20 = VEC_PERM_EXPR <vect__5.5_19, vect__5.5_19, { 1, 0 }>
could have been elided.

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

* [Bug tree-optimization/101178] SLP permute propagation doesn't handle VEC_PERM
  2021-06-23 10:12 [Bug tree-optimization/101178] New: SLP permute propagation doesn't handle VEC_PERM rguenth at gcc dot gnu.org
@ 2021-06-23 10:12 ` rguenth at gcc dot gnu.org
  2021-06-24  7:37 ` rguenth at gcc dot gnu.org
                   ` (2 subsequent siblings)
  3 siblings, 0 replies; 5+ messages in thread
From: rguenth at gcc dot gnu.org @ 2021-06-23 10:12 UTC (permalink / raw)
  To: gcc-bugs

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

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

           What    |Removed                     |Added
----------------------------------------------------------------------------
           Assignee|unassigned at gcc dot gnu.org      |rguenth at gcc dot gnu.org
     Ever confirmed|0                           |1
                 CC|                            |tnfchris at gcc dot gnu.org
           Keywords|                            |missed-optimization
   Last reconfirmed|                            |2021-06-23
             Status|UNCONFIRMED                 |ASSIGNED

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

* [Bug tree-optimization/101178] SLP permute propagation doesn't handle VEC_PERM
  2021-06-23 10:12 [Bug tree-optimization/101178] New: SLP permute propagation doesn't handle VEC_PERM rguenth at gcc dot gnu.org
  2021-06-23 10:12 ` [Bug tree-optimization/101178] " rguenth at gcc dot gnu.org
@ 2021-06-24  7:37 ` rguenth at gcc dot gnu.org
  2021-07-01  7:48 ` cvs-commit at gcc dot gnu.org
  2021-07-01  7:48 ` rguenth at gcc dot gnu.org
  3 siblings, 0 replies; 5+ messages in thread
From: rguenth at gcc dot gnu.org @ 2021-06-24  7:37 UTC (permalink / raw)
  To: gcc-bugs

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

--- Comment #1 from Richard Biener <rguenth at gcc dot gnu.org> ---
Another case:

double a[2], b[2], c[2];

void foo ()
{
  double tem0 = a[1] + b[1];
  double tem1 = a[0] - b[0];
  c[0] = tem0;
  c[1] = tem1;
}

here the addsub VEC_PERM merge node has wrong order (+, - instead of -, +)
for x86 addsub at the place we currently match for SLP patterns.  But if
we'd move the load permutations across this node we can not only save
one permute but also match x86 addsub.

Currently optimize_slp materializes the perms at the addsub VEC_PERM merge
node which does the trick (but pattern matching was too early here).
It will be a cost thing to decide whether to materialize here or to hope
for eliding another permute up the chain.

double a[2], b[2], c[2];

void foo ()
{
  double tem0 = a[1] - b[1];
  double tem1 = a[0] + b[0];
  c[0] = tem0;
  c[1] = tem1;
}

is currently miscompiled when we first match .ADDSUB since then optimize_slp
happily treats it as lane agnostic operation.  That's probably a latent
wrong-code issue on the branch as well.

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

* [Bug tree-optimization/101178] SLP permute propagation doesn't handle VEC_PERM
  2021-06-23 10:12 [Bug tree-optimization/101178] New: SLP permute propagation doesn't handle VEC_PERM rguenth at gcc dot gnu.org
  2021-06-23 10:12 ` [Bug tree-optimization/101178] " rguenth at gcc dot gnu.org
  2021-06-24  7:37 ` rguenth at gcc dot gnu.org
@ 2021-07-01  7:48 ` cvs-commit at gcc dot gnu.org
  2021-07-01  7:48 ` rguenth at gcc dot gnu.org
  3 siblings, 0 replies; 5+ messages in thread
From: cvs-commit at gcc dot gnu.org @ 2021-07-01  7:48 UTC (permalink / raw)
  To: gcc-bugs

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

--- Comment #2 from CVS Commits <cvs-commit at gcc dot gnu.org> ---
The master branch has been updated by Richard Biener <rguenth@gcc.gnu.org>:

https://gcc.gnu.org/g:7d8211603a3d04384812b481b0ae01205a287a72

commit r12-1949-g7d8211603a3d04384812b481b0ae01205a287a72
Author: Richard Biener <rguenther@suse.de>
Date:   Wed Jun 30 16:28:50 2021 +0200

    tree-optimization/101178 - handle VEC_PERM in SLP permute propagation

    This adds handling of VEC_PERM nodes to SLP permute propagation.
    Previously VEC_PERM acted as forced materialization of incoming
    permutes since it is a good place to do that (with the constraint
    of those only appearing for two-operator nodes).  The following
    patch, in addition to supporting (but not forcing) this, enables
    VEC_PERM nodes acting as "any" permute on the outgoing side since
    they also can consume arbitrary permutes on that side.

    This again (meh) changes how we represent permutes and materialization
    on the graph vertices now explicitely having the common incoming
    permute as well as an outgoing permute and in case both are
    different the vertex acts as materialization point of the incoming
    permute.

    2021-06-30  Richard Biener  <rguenther@suse.de>

            PR tree-optimization/101178
            * tree-vect-slp.c (slpg_vertex::materialize): Remove.
            (slpg::perm_in): Add.
            (slpg::get_perm_in): Remove.
            (slpg::get_perm_materialized): Add.
            (vect_optimize_slp): Handle VEC_PERM nodes more optimally
            during permute propagation and materialization.

            * gcc.dg/vect/bb-slp-72.c: New testcase.
            * gcc.dg/vect/bb-slp-73.c: Likewise.
            * gcc.dg/vect/bb-slp-74.c: Likewise.

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

* [Bug tree-optimization/101178] SLP permute propagation doesn't handle VEC_PERM
  2021-06-23 10:12 [Bug tree-optimization/101178] New: SLP permute propagation doesn't handle VEC_PERM rguenth at gcc dot gnu.org
                   ` (2 preceding siblings ...)
  2021-07-01  7:48 ` cvs-commit at gcc dot gnu.org
@ 2021-07-01  7:48 ` rguenth at gcc dot gnu.org
  3 siblings, 0 replies; 5+ messages in thread
From: rguenth at gcc dot gnu.org @ 2021-07-01  7:48 UTC (permalink / raw)
  To: gcc-bugs

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

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

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

--- Comment #3 from Richard Biener <rguenth at gcc dot gnu.org> ---
Fixed.

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

end of thread, other threads:[~2021-07-01  7:48 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-06-23 10:12 [Bug tree-optimization/101178] New: SLP permute propagation doesn't handle VEC_PERM rguenth at gcc dot gnu.org
2021-06-23 10:12 ` [Bug tree-optimization/101178] " rguenth at gcc dot gnu.org
2021-06-24  7:37 ` rguenth at gcc dot gnu.org
2021-07-01  7:48 ` cvs-commit at gcc dot gnu.org
2021-07-01  7:48 ` rguenth 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).