public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug tree-optimization/59299] New: We do not sink loads
@ 2013-11-26 13:37 rguenth at gcc dot gnu.org
  2013-11-28 12:12 ` [Bug tree-optimization/59299] " rguenth at gcc dot gnu.org
                   ` (3 more replies)
  0 siblings, 4 replies; 5+ messages in thread
From: rguenth at gcc dot gnu.org @ 2013-11-26 13:37 UTC (permalink / raw)
  To: gcc-bugs

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

            Bug ID: 59299
           Summary: We do not sink loads
           Product: gcc
           Version: 4.9.0
            Status: UNCONFIRMED
          Keywords: missed-optimization
          Severity: normal
          Priority: P3
         Component: tree-optimization
          Assignee: unassigned at gcc dot gnu.org
          Reporter: rguenth at gcc dot gnu.org

When fixing PR57517 I noticed that we don't sink loads leading to that PR

int x[1024], y[1024], z[1024], w[1024];
void foo (void)
{
  int i;
  for (i = 1; i < 1024; ++i)
    {
      int a = x[i];
      int b = y[i];
      int c = x[i-1];
      int d = y[i-1];
      if (w[i])
        z[i] = (a + b) + (c + d);
    }
}

results in

  <bb 4>:
  # i_18 = PHI <i_15(3), 1(2)>
  a_5 = x[i_18];
  b_6 = y[i_18];
  _7 = i_18 + -1;
  c_8 = x[_7];
  d_9 = y[_7];
  _10 = w[i_18];
  if (_10 != 0)
    goto <bb 5>;
  else
    goto <bb 8>;

  <bb 8>:
  goto <bb 6>;

  <bb 5>:
  _11 = a_5 + b_6;
  _12 = c_8 + d_9;
  _13 = _11 + _12;
  z[i_18] = _13;

  <bb 6>:
  i_15 = i_18 + 1;
  if (i_15 != 1024)
    goto <bb 3>;
  else
    goto <bb 7>;

instead of

  <bb 4>:
  # i_18 = PHI <i_15(3), 1(2)>
  _10 = w[i_18];
  if (_10 != 0)
    goto <bb 5>;
  else
    goto <bb 8>;

  <bb 8>:
  goto <bb 6>;

  <bb 5>:
  a_5 = x[i_18];
  b_6 = y[i_18];
  _7 = i_18 + -1;
  c_8 = x[_7];
  d_9 = y[_7];
  _11 = a_5 + b_6;
  _12 = c_8 + d_9;
  _13 = _11 + _12;
  z[i_18] = _13;

  <bb 6>:
  i_15 = i_18 + 1;
  if (i_15 != 1024)
    goto <bb 3>;
  else
    goto <bb 7>;

note that we eventually sink all computations into the if arm but only
stop at the loads.

tree-ssa-sink.c says:

@@ -294,8 +285,6 @@ statement_sink_location (gimple stmt, ba
      be seen by an external routine that needs it depending on where it gets
      moved to.

-     We don't want to sink loads from memory.
-
      We can't sink statements that end basic blocks without splitting the
      incoming edge for the sink location to place it there.

but doesn't give a good reason IMHO.

I have a simple patch.


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

* [Bug tree-optimization/59299] We do not sink loads
  2013-11-26 13:37 [Bug tree-optimization/59299] New: We do not sink loads rguenth at gcc dot gnu.org
@ 2013-11-28 12:12 ` rguenth at gcc dot gnu.org
  2014-06-06 15:33 ` rguenth at gcc dot gnu.org
                   ` (2 subsequent siblings)
  3 siblings, 0 replies; 5+ messages in thread
From: rguenth at gcc dot gnu.org @ 2013-11-28 12:12 UTC (permalink / raw)
  To: gcc-bugs

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

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

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|UNCONFIRMED                 |ASSIGNED
   Last reconfirmed|                            |2013-11-28
           Assignee|unassigned at gcc dot gnu.org      |rguenth at gcc dot gnu.org
     Ever confirmed|0                           |1


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

* [Bug tree-optimization/59299] We do not sink loads
  2013-11-26 13:37 [Bug tree-optimization/59299] New: We do not sink loads rguenth at gcc dot gnu.org
  2013-11-28 12:12 ` [Bug tree-optimization/59299] " rguenth at gcc dot gnu.org
@ 2014-06-06 15:33 ` rguenth at gcc dot gnu.org
  2014-06-10 10:30 ` rguenth at gcc dot gnu.org
  2021-08-08 20:08 ` pinskia at gcc dot gnu.org
  3 siblings, 0 replies; 5+ messages in thread
From: rguenth at gcc dot gnu.org @ 2014-06-06 15:33 UTC (permalink / raw)
  To: gcc-bugs

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

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

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

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


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

* [Bug tree-optimization/59299] We do not sink loads
  2013-11-26 13:37 [Bug tree-optimization/59299] New: We do not sink loads rguenth at gcc dot gnu.org
  2013-11-28 12:12 ` [Bug tree-optimization/59299] " rguenth at gcc dot gnu.org
  2014-06-06 15:33 ` rguenth at gcc dot gnu.org
@ 2014-06-10 10:30 ` rguenth at gcc dot gnu.org
  2021-08-08 20:08 ` pinskia at gcc dot gnu.org
  3 siblings, 0 replies; 5+ messages in thread
From: rguenth at gcc dot gnu.org @ 2014-06-10 10:30 UTC (permalink / raw)
  To: gcc-bugs

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

--- Comment #3 from Richard Biener <rguenth at gcc dot gnu.org> ---
Author: rguenth
Date: Tue Jun 10 10:29:44 2014
New Revision: 211404

URL: http://gcc.gnu.org/viewcvs?rev=211404&root=gcc&view=rev
Log:
2014-06-10  Richard Biener  <rguenther@suse.de>

    PR tree-optimization/57186
    PR tree-optimization/59299
    * gcc.dg/tree-ssa/ssa-sink-11.c: New testcase.
    * gcc.dg/tree-ssa/ssa-sink-12.c: Likewise.

Added:
    trunk/gcc/testsuite/gcc.dg/tree-ssa/ssa-sink-11.c
    trunk/gcc/testsuite/gcc.dg/tree-ssa/ssa-sink-12.c
Modified:
    trunk/gcc/testsuite/ChangeLog


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

* [Bug tree-optimization/59299] We do not sink loads
  2013-11-26 13:37 [Bug tree-optimization/59299] New: We do not sink loads rguenth at gcc dot gnu.org
                   ` (2 preceding siblings ...)
  2014-06-10 10:30 ` rguenth at gcc dot gnu.org
@ 2021-08-08 20:08 ` pinskia at gcc dot gnu.org
  3 siblings, 0 replies; 5+ messages in thread
From: pinskia at gcc dot gnu.org @ 2021-08-08 20:08 UTC (permalink / raw)
  To: gcc-bugs

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

Andrew Pinski <pinskia at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
   Target Milestone|---                         |5.0

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

end of thread, other threads:[~2021-08-08 20:08 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2013-11-26 13:37 [Bug tree-optimization/59299] New: We do not sink loads rguenth at gcc dot gnu.org
2013-11-28 12:12 ` [Bug tree-optimization/59299] " rguenth at gcc dot gnu.org
2014-06-06 15:33 ` rguenth at gcc dot gnu.org
2014-06-10 10:30 ` rguenth at gcc dot gnu.org
2021-08-08 20:08 ` pinskia 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).